Skip to content

Instantly share code, notes, and snippets.

@ioncreature
Created October 12, 2012 15:29
Show Gist options
  • Save ioncreature/3879777 to your computer and use it in GitHub Desktop.
Save ioncreature/3879777 to your computer and use it in GitHub Desktop.
ES6 arrow function syntax
// 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