Compare commits

...

3 Commits

Author SHA1 Message Date
jason.zhu 2ad7483250 Module3: What is bind method? 2021-05-12 17:02:11 +10:00
jason.zhu 6a0a672e35 What is the apply Method? 2021-05-12 13:48:15 +10:00
jason.zhu 0c245858e6 Module3: What is the call Method? 2021-05-12 13:36:32 +10:00
1 changed files with 11 additions and 11 deletions

22
app.js
View File

@ -1,11 +1,11 @@
let message = {
name: 'John',
regularFunction: function() {
console.log(this)
console.log('Hello ' + this.name);
},
arrowFunction: () => console.log(this)
}
message.regularFunction();
message.arrowFunction(); //
let person1 = {
name: 'Mary',
getName: function(){
return this.name;
}
};
let person2 = {
name: 'John'
};
let getNameCopy = person1.getName.bind(person2); // won't change context of function
console.log(getNameCopy());