Compare commits
3 Commits
e6874571ca
...
2ad7483250
Author | SHA1 | Date |
---|---|---|
jason.zhu | 2ad7483250 | |
jason.zhu | 6a0a672e35 | |
jason.zhu | 0c245858e6 |
22
app.js
22
app.js
|
@ -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());
|
Loading…
Reference in New Issue