Created
September 8, 2015 19:26
-
-
Save Restuta/b34bfc6f162af9b3f7eb to your computer and use it in GitHub Desktop.
Arrow functions and "this"
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
function Foo() { | |
setTimeout( | |
function() { console.log(this); }, | |
200); | |
} | |
function Bar() { | |
setTimeout( | |
() => { console.log(this); }, | |
200); | |
} | |
new Foo(); //prints window | |
new Bar(); //prints Bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment