Created
October 24, 2017 16:52
-
-
Save carlosmaniero/3f19a708121bff1d57f3631d8bfff4c3 to your computer and use it in GitHub Desktop.
Arrow functions is not a syntax sugar for functions
This file contains hidden or 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
const withFunction = { | |
myOwnProp: 42, | |
myOwnFunc: function () { | |
return this.myOwnProp | |
} | |
} | |
const withArrow = { | |
myOwnProp: 42, | |
myOwnFunc: () => { | |
return this.myOwnProp | |
} | |
} | |
console.log(withFunction.myOwnFunc()) // 42 | |
console.log(withArrow.myOwnFunc()) // undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment