Skip to content

Instantly share code, notes, and snippets.

@flarnie
Last active August 29, 2015 14:07
Show Gist options
  • Save flarnie/f671e874addb5c8bb594 to your computer and use it in GitHub Desktop.
Save flarnie/f671e874addb5c8bb594 to your computer and use it in GitHub Desktop.
ES6 Fat Arrow Functions
// ES6 "fat arrow functions"
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
// One-line shorthand
var sayHello = (name) => console.log('Hello ', name);
// Multi-line example
var sayHelloTwice = (name) => {
console.log('Hello ', name);
console.log('Hi again ', name);
};
// ES5 compatible syntax transpiled by es6-transpiler
// https://github.com/termi/es6-transpiler
// One-line shorthand
var this$0 = this;
var sayHello = function(name) { console.log('Hello ', name); };
// Multi-line example
var this$1 = this;
var sayHelloTwice = function(name) {
console.log('Hello ', name);
console.log('Hi again ', name);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment