Skip to content

Instantly share code, notes, and snippets.

View HashirHussain's full-sized avatar
🎯

Hashir Hussain HashirHussain

🎯
View GitHub Profile
@HashirHussain
HashirHussain / arrow-functions.js
Created September 6, 2018 16:44
Provide quick understanding of ES6 Arrow functions.
/*
Arrow functions are a shorthand for anonymous functions in JavaScript.
Unlike function, arrows share the same lexical `this` as their surroundings bodies.
*/
//Expression bodies
var result = items.map(v => v + 1);
var result = items.map((v, i) => v + i);
var result = items.map((v, i) => ({item: v, key: i}));