I am trying to create an Array using new Array()
and filling with index + 1 but somehow, though array is creating successfully but values are not filling correctly.
Code -
var aa = (new Array(4)).map((x, index) => {
return index + 1;
});
console.log(aa);
Output - [undefined, undefined, undefined, undefined]
Expected - [1, 2, 3, 4]
Let me know what I am doing wrong here.