Skip to content

Instantly share code, notes, and snippets.

@jasonals
Last active August 29, 2015 14:20
Show Gist options
  • Save jasonals/b88021a74955d64f356d to your computer and use it in GitHub Desktop.
Save jasonals/b88021a74955d64f356d to your computer and use it in GitHub Desktop.
ES6 arrow functions
const x = {a:1, b:2, c:3};
const func1 = () => "no params";
const func2 = ({a}) => a;
const func3 = y => y;
const func4 = ({b,c}) => ({b,c}); // return object
const func5 = ({b,c}) => b + c;
const func6 = ({b,c}) => { return b + c; };
func1(); // no params
func2(x); // 1
func3(x); // {a:1, b:2, c:3}
func4(x); // {b:2, c:3}
func5(x); // 5
func6(x); // 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment