Created
December 10, 2016 15:02
-
-
Save paulwib/ba30434b1fc3f7cd9e415c5f55fa970c to your computer and use it in GitHub Desktop.
Fat arrow fail
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
var foo = () => console.log(this); // foo() - `this` is undefined | |
var bar = function() { console.log(this) }; // bar() -`this` is window (in browser) | |
var fred = function() { console.log(arguments) }; // fred(1) - [1] | |
var dave = () => console.log(arguments); // dave(1) - Reference error, arguments is undefined! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://rainsoft.io/when-not-to-use-arrow-functions-in-javascript/ for more confusion.