I expected the first console.log to be [0,10,20,30] and the second to be [0,100,20,30]:
var arr = [0,10,20,30]
console.log(arr)
arr.forEach(each)
console.log(arr)
function each(data,index) {
if (index === 1) {
data = 100 // This isn't assigned to arr[1]
}
}
No comments:
Post a Comment