Last active
November 16, 2017 19:41
-
-
Save KinoAR/b1928e0482d2d7e2d9cbff356d3b557a to your computer and use it in GitHub Desktop.
Showcasing the power of arrow functions.
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
//Arrow Functions | |
console.log(identity); //Undefined - Function is not hoisted | |
var identity = x => x ; | |
console.log(identity); //Function or x => x | |
//console.log(new identity()); //Error - not a constructor | |
//Context Example | |
function test2() { | |
console.log(this); //test2 - this refers to the object | |
var test3 = x => console.log(this); | |
function test4() { | |
console.log(this); | |
} | |
test3(); //Refers to test2 | |
var b = new test4(); //Refers to test4 | |
} | |
var a = new test2(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment