Last active
August 16, 2018 11:06
-
-
Save CodHeK/2a156913b7adbd39a70eab7562980335 to your computer and use it in GitHub Desktop.
fat 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
//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