So I noticed today that if you create an Array using the non-usual new Array(<array_length>)
syntax, you will be unable to map over the values correctly.
A simple example:
var newArr = new Array(10);
newArr = newArr.map(function(val) {
alert("It's really happening!");
return 200;
});
console.log(newArr);
The result after running is still an empty array, nor does any of the alert
's fire off.
Any ideas why the new Array()
s passed in .map()
function doesn't work in this example?