Create a gist now

Instantly share code, notes, and snippets.

Embed
Arrow Functions Examples For Blog Post
//Array of birthyear.
const years = [1992, 1978, 1986, 1995];
//Calculating age with a normal function.
var ages = years.map( function(yr) {
return 2018 - yr;
});
console.log(ages);
//Calculating age with an arrow function.
const anotherAge = years.map(yr => 2018 - yr);
console.log(anotherAge);
//Arrow function example with single argument.
const multiply = number => number * 15;
console.log(multiply(5));
//Arrow function example with multiple arguments.
const nameAge = (name, age) => {
console.log(name, age);
}
nameAge('Imtiaz', 22);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment