Quantcast
Channel: How to instantiate a javascript array with the same value - Stack Overflow
Browsing latest articles
Browse All 3 View Live

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 Article


Answer 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 Article


How 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
Browsing latest articles
Browse All 3 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>