javascript - Why map doesn't work on new Array in js -


this question has answer here:

why code bellow returns array of undefined values , don't see logs?

var arr = new array(10); arr = arr.map(function () {     console.log('kapa');     return 1; }); console.log(arr); 

you can use array.apply

array.apply(null, {length: 10}).map(function(){return 1}) 

Comments