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