↧
Answer by dereference for How to instantiate a javascript array with the same...
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);...
View ArticleAnswer by isherwood for How to instantiate a javascript array with the same...
var myArray = []; function pointsArray(totalPoints) { for (i = 0; i < totalPoints; i++) { myArray.push(1); } return myArray; } http://jsfiddle.net/isherwood/CvscV
View ArticleHow to instantiate a javascript array with the same value
I want to type something like [1] * totalPoints so that if totalPoints was 3, it would give me an array of [1,1,1]. I can't think of what it would be called though.. as such, my searches have turned...
View Article