Skip to content

Instantly share code, notes, and snippets.

@CodHeK
Last active August 16, 2018 11:06
Show Gist options
  • Save CodHeK/2a156913b7adbd39a70eab7562980335 to your computer and use it in GitHub Desktop.
Save CodHeK/2a156913b7adbd39a70eab7562980335 to your computer and use it in GitHub Desktop.
fat arrow functions
//tradional way
function fn(a, b) {
return a + b;
}
//using fat arrow style
var fn = (a, b) => a + b;
var fn = (a, b) => {
return a + b;
}
//if only one parameter
var fn = a => a + 5;
//if no paramter
var fn = () => {
let a = 3;
let b = 4;
return a + b;
}
var fn = () => console.log("Hello")
//How it can be used
setTimeout(() => console.log("Hello"), 1000); //will print "Hello" after 1 second
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment