I want to change the current object in for each loop and it does not work, Why it is not working and how can i do this?
var arr = [{num: 1}, {num: 2}]; arr.
You are changing the local reference item in the callback function.
item
To change array contents, you need to use the array index and assign new reference to it, as shown in below
arr.forEach(function(item, i) { arr[i] = {somethingElse: 1} //using index, change the reference in array });