Skip to content

Instantly share code, notes, and snippets.

@carlosmaniero
Created October 24, 2017 16:52
Show Gist options
  • Save carlosmaniero/3f19a708121bff1d57f3631d8bfff4c3 to your computer and use it in GitHub Desktop.
Save carlosmaniero/3f19a708121bff1d57f3631d8bfff4c3 to your computer and use it in GitHub Desktop.
Arrow functions is not a syntax sugar for functions
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