Skip to content

Instantly share code, notes, and snippets.

@sampathsl sampathsl/index5.js
Last active Dec 13, 2015

Embed
What would you like to do?
Arrow Function Usage
//ES 5
function isBigEnough(value) {
return value >= 10;
}
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough);
console.log(filtered);
//ES 6
let filtered_extended = [12, 5, 8, 130, 44].filter((e) => {
return e >= 10;
});
console.log(filtered_extended);
//ES 5
var numbers = [1,2,3,4,5];
var timesTwo = numbers.map(function (number) {
return number * 2;
});
console.log(timesTwo); // [2, 4, 6, 8, 10]
//ES 6
let numbers_es6 = [1,2,3,4,5];
let timesTwo_es6 = numbers_es6.map((number) => number * 2);
console.log(timesTwo_es6); // [2, 4, 6, 8, 10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.