Last active
May 30, 2016 02:01
-
-
Save shaunxu/fb94fc6d4c6b6afbcb1d8f85573a2c69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
constructor (firstName) { | |
this.firstName = firstName; | |
this.sayHiArrowFn = () => { | |
console.log(this); | |
} | |
this.sayHiFn = function () { | |
console.log(this); | |
} | |
} | |
} | |
const p1 = new Person('Shaun'); | |
const sayHiArrowFn = p1.sayHiArrowFn; | |
sayHiArrowFn(); // Person { firstName: 'Shaun', sayHiArrowFn: [Function], sayHiFn: [Function] } | |
const sayHiFn = p1.sayHiFn; | |
sayHiFn(); // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment