-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay28Callapply.html
34 lines (31 loc) · 1.07 KB
/
Day28Callapply.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Day28</title>
</head>
<body>
<script>
//Call in javascript
let name={
firstname:'ponmani',
Lastname:'venkatesan',
Printname:function(word,profession){
return (`Hello ${this.firstname} ${this.Lastname} ${word} ${profession}`);//this refers to current obj
}
}
let name2={
firstname:'Kamal',
Lastname:'Hassan',
//instead writing function again we are borrowing thatt funtion here
}
//here
let nameval=name.Printname.call(name2,'welcome');// we are sending this info of name2 to function--printname
console.log(nameval);// Hello kamal hasan welcome
//apply in js
let nameval1=name.Printname.apply(name2,['welcome','cinema']);//we can send parameters in array in apply
console.log(nameval1);//Hello kamal hasan welcome cinema
</script>
</body>
</html>