Skip to content

Instantly share code, notes, and snippets.

@savelee
Last active July 25, 2016 14:02
Show Gist options
  • Save savelee/08febddb14693e2603372bc5b8a43ecb to your computer and use it in GitHub Desktop.
Save savelee/08febddb14693e2603372bc5b8a43ecb to your computer and use it in GitHub Desktop.
Example of Arrow Functions
//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
//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