Here you can find the source of range()
Array.prototype.range = function() { var min = null, max = null,/*from ww w. j a v a 2 s.c om*/ sum = null, i, len; for (i = 0, len = this.length; i < len; ++i) { var elem = this[i]; sum += elem; if (min === null || min > elem) min = elem; if (max === null || max < elem) max = elem; } return { min: min, max: max, avg: Math.floor(sum / len), len: len }; }; Array.max = function(array) { return Math.max.apply(Math, array); }; Array.min = function(array) { return Math.min.apply(Math, array); }; Math.floor10 = function(value) { return decimalAdjust('floor', value, -1); }; function decimalAdjust(type, value, exp) { if (typeof exp === 'undefined' || +exp === 0) { return Math[type](value); } value = +value; exp = +exp; if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) { return NaN; } value = value.toString().split('e'); value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp))); value = value.toString().split('e'); return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp)); }
Array.prototype.range = function(){ var a = this.natsort(); return this[a.length-1]-a[0]; };
Array.prototype.range = function() { function isArray(instance) { return Object.prototype.toString.call(instance) !== '[object Array]'; if (!isArray(this)) { throw new TypeError("`this` must be Array, not " + typeof this); if (arguments.length === 0) { throw new TypeError("Missing required argument(s)"); ...
Array.range = function (end, step) { var array = []; for (var i = step; i <= end; i += step) { array.push(i); return array;
Array.prototype.range = function(first, second) { var range = [] console.log(typeof second) if (typeof second === 'undefined') { for (var i = 0; i < first; i++) { range.push(i) return range for (var i = first; i < second; i++) { range.push(i) return range
Array.prototype.range = function(from, to) { var result = [] while (from <= to) result.push(from++) return result
Array.prototype.range = function(from, to) { var i, result = []; for (i = from; i<= to; i++) { result.push(i); return result; }; console.log([].range(1, 10));