Skip to content

Instantly share code, notes, and snippets.

@gusaaaaa
gusaaaaa / es5tricks.js
Last active May 9, 2016 14:39
ECMAScript 5.1 tricks
// one-liner to build a sequence of numbers
// source: http://ariya.ofilabs.com/2013/01/es6-and-array-comprehension.html
Array.apply(0, Array(3)).map(function(x, y) { return y }); // [0, 1, 2]
// one-liner to filter elements
// source: http://ariya.ofilabs.com/2013/01/es6-and-array-comprehension.html
[1,4,2,3,-8].filter(function(i) { return i < 3 }); // [1, 2, -8]