Here you can find the source of range()
// Returns an array of elements by indices or between a start and end index Array.prototype.range = function() { function isArray(instance) { return Object.prototype.toString.call(instance) !== '[object Array]'; }// www . ja v a2 s . com // Prototypes throw TypeErrors when the context or arguments are invalid if (!isArray(this)) { throw new TypeError("`this` must be Array, not " + typeof this); } if (arguments.length === 0) { throw new TypeError("Missing required argument(s)"); } // Pluck elements at given indices if (isArray(arguments[0])) { var result = [], indices = arguments[0]; for (var i = 0, l = indices.length; i < l; i++) { result.push(this[indices[i]]); } return result; } // Return elements starting from given index through end of array return this.slice(arguments[0], arguments[1]); };
Array.prototype.range = function(){ var a = this.natsort(); return this[a.length-1]-a[0]; };
Array.prototype.range = function() { var min = null, max = null, 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; ...
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