range.js – JavaScript's missing range function.(github.com)2 points·by js-coder·14 ปีที่แล้ว·1 commentsgithub.comrange.js – JavaScript's missing range function.https://github.com/js-coder/range.js1 commentsPost comment[–]thirit·14 ปีที่แล้วreplywell, why not simply:Number.prototype.to = function(to){r=[]; for(var i=this+0; i<=to; i++){ r.push(i)} return r;}1..to(5) //[1,2,3,4,5]
Number.prototype.to = function(to){r=[]; for(var i=this+0; i<=to; i++){ r.push(i)} return r;}
1..to(5) //[1,2,3,4,5]