Compare commits
3 Commits
e6874571ca
...
2ad7483250
Author | SHA1 | Date |
---|---|---|
jason.zhu | 2ad7483250 | |
jason.zhu | 6a0a672e35 | |
jason.zhu | 0c245858e6 |
20
app.js
20
app.js
|
@ -1,11 +1,11 @@
|
|||
let message = {
|
||||
name: 'John',
|
||||
regularFunction: function() {
|
||||
console.log(this)
|
||||
console.log('Hello ' + this.name);
|
||||
},
|
||||
arrowFunction: () => console.log(this)
|
||||
let person1 = {
|
||||
name: 'Mary',
|
||||
getName: function(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
message.regularFunction();
|
||||
message.arrowFunction(); //
|
||||
};
|
||||
let person2 = {
|
||||
name: 'John'
|
||||
};
|
||||
let getNameCopy = person1.getName.bind(person2); // won't change context of function
|
||||
console.log(getNameCopy());
|
Loading…
Reference in New Issue