Last active
July 25, 2016 14:02
-
-
Save savelee/08febddb14693e2603372bc5b8a43ecb to your computer and use it in GitHub Desktop.
Example of Arrow Functions
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
//ES6 arrow functions | |
var calculate = (x,y) => { | |
return x + y; | |
} | |
var sayHello = (name) => { | |
return "Hello " + name; | |
} | |
//or: | |
var calculate = (x,y) => x + y; | |
var sayHello = (name) => "Hello " + name; | |
calculate(5,10); //returns: 15 | |
sayHello('Lee'); //returns: Hello Lee |
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
//ES5 functions | |
var calculate = function(x,y){ | |
return x + y; | |
} | |
var sayHello = function(name){ | |
return "Hello " + name; | |
} | |
calculate(5,10); //returns: 15 | |
sayHello('Lee'); //returns: Hello Lee |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment