Here you can find the source of range(start,end,step)
/**//w w w . j ava 2 s . c om * Created by xiaos on 16/11/24. */ Array.prototype.range = (start,end,step)=>{ const stepVal = step || 1 const set = new Set() for (var i=start;i<=end;i=i+stepVal){ set.add(i) } return [...set] } Set.prototype.union = function (set) { return new Set([...this,...set]) } Set.prototype.inrs = function (set) { let arr = [...this].filter(v=>set.has(v)) return new Set(arr) } Set.prototype.diff = function (set) { let arr = [...this].filter(v=>!set.has(v)) return new Set(arr) } module.exports = { page(page,count,maxCount,action){ const maxPage = Math.ceil(maxCount/count) const data = {} if (page >= maxPage){ data.last = true data.pre = Math.max(1,maxPage-1) }else if (page == 1){ data.first = true data.next = page + 1 }else { data.pre = page - 1 data.next = page + 1 } data.action = action return data } }
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));
Array.range = function(start, count) { var arr = [], val = start; while(count > 0) { arr.push(val); count--; val++; return arr; ...
Array.range = function (start, end) { var a = [], i; for (i = start; i < end; i += 1) { a[i] = i; return a;
Array.prototype.range = function(start, end) { var result = []; for (var i = start; i <= end; i++) { result.push(i); return result;
Array.prototype.range = function(start,end){ return Array.apply(null, Array(end-start+1)).map(function (_, i){ return start+i; }); };
Array.prototype.rangeArray = function (startIndex, endIndex) { var arr = [] for(var i=startIndex; i<endIndex; i++) { arr.push(i); return arr;