Array.prototype.range
Array.prototype.range = function(a, b, step) {
step = !step ? 1 : step;
b = b / step;
for(var i = a; i <= b; i++) {
this.push(i*step);
}
return this;
};
var myarray = [];
myarray.range(0, 10, 2); // returns 0, 2, 4, 6, 8, 10
Written by James Doyle
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Array
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#