Skip to content

Instantly share code, notes, and snippets.

@KinoAR
Last active November 16, 2017 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KinoAR/b1928e0482d2d7e2d9cbff356d3b557a to your computer and use it in GitHub Desktop.
Save KinoAR/b1928e0482d2d7e2d9cbff356d3b557a to your computer and use it in GitHub Desktop.
Showcasing the power of arrow functions.
//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