Number.prototype.n = function () {
var a=[],self=this;
(new Array(n+2)).toString().replace(/,/g,function(){
arguments[1]>=self&&a.push(arguments[1]) })
return a; }
var n = 12
var x = 1..n ()
alert(x)
原创:司徒正美
Number.prototype.n = function () { for(var i = +this, a = []; i <= n; a.push(i++)); return a; }
var n = 15
var x = 6..n ()
alert(x)//6,7,8,9,10,11,12,13,14,15
|
Qwrap abcd前辈的实现方法
function mstr(s) {
return s.replace(/[\s\S]-[\s\S]/g, function(s) {
var m = s.charCodeAt(0);var n = s.charCodeAt(2);
for (s = ''; m <= n; m++)s += String.fromCharCode(m);
return s;});} // mstr('0-3') => '0123'