Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
range.js – JavaScript's missing range function. (github.com/js-coder)
2 points by js-coder on Dec 20, 2012 | hide | past | favorite | 1 comment


well, 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]




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: