Last Updated: February 25, 2016
·
1.082K
· james2doyle

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