[Solved] How can I create an array of sequential values from a value?


You can just use a loop and do:

var a = 5;
var arr = [];

for(var i=0; i<a; i++) {
   arr.push(i);    
}

As others have stated in their answers,

Array direct assignment is even faster than Push

Having used jsperf, that appears to be incorrect for Chrome/Firefox. See below:

enter image description here

http://jsperf.com/js-array232

From this, I would use push as stated in my answer above.

5

solved How can I create an array of sequential values from a value?