Created
October 12, 2012 15:29
-
-
Save ioncreature/3879777 to your computer and use it in GitHub Desktop.
ES6 arrow function syntax
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
// You can check this with Google Traceur Compiller | |
// http://code.google.com/p/traceur-compiler/ | |
class Test { | |
constructor(){ | |
var self = this, | |
fn = () => this === self, | |
fnOld = function(){ return this === self }; | |
console.log( 'fn', fn(), 'fnOld', fnOld() ); | |
} | |
} | |
var test = new Test(); | |
/* | |
Console shows: | |
"fn" true "fnOld" false | |
I think this awful - else one ambiguous place in JS, it can eat many-many | |
time to investigate that behaviour of 'fn' and 'fnOld' is different. | |
http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment