Last active
August 29, 2015 14:20
-
-
Save jasonals/b88021a74955d64f356d to your computer and use it in GitHub Desktop.
ES6 arrow functions
This file contains hidden or 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
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