I have a question about map.As you know by using map we can iterate arrays and able to change the element of arrays.To do that there are two ways and I listed them below.Which way has less complexity and more performance?(In the examples arrays are not big but think about the real world like 500 elements in an array)
var numbers = [4, 9, 16, 25];
numbers=numbers.map(e=>{
return e=e*2;
})
In this approach assigning each returned value to current array.
numbers.map((e,a)=>{
numbers[a]=e*2;
})
In this one on each iteration we need to go to array by index to find element and I think this is worse than above but Im not sure.