let arr = [{
first: "kobi"
},
{
first: "kobi2"
},
{
first: "kobi3"
},
]
let arr2 = []
arr2 = arr.map((v) => {
let neww = v
console.log(v);
neww.first = "worng"
console.log(v);
return neww
})
console.log(arr2); //["worng","worng","worng"]
console.log(arr); //["worng","worng","worng"]
the original array changed too! But when I use an array without object, it seems to be that the original array didn't change a bit! And I cant figure why...for example I added another arrays without objects
let orderArray = [11, 12, 13, 14];
let newArray = [];
newArray = orderArray.map((value) => {
let newPrice = value * 4;
return newPrice;
});
console.log(orderArray); // [11, 12, 13, 14]
console.log(newArray); //[44,48,52,56]
the original array didn't change!