Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by dereference for How to instantiate a javascript array with the same value

Create a new array of size 3 then use the array map function on each element, calling valueOf:

var totalPoints = Array.apply(null, new Array(3)).map(Number.prototype.valueOf,1);

http://jsfiddle.net/pXgu4/


Viewing all articles
Browse latest Browse all 3

Trending Articles