Push is overwriting previous data in array

Calling push will not copy your object, because JavaScript Objects are passed by reference: you’re pushing the same Object as every array entry.

You can fix this easily by moving the var UserDataEntry = {}; inside the loop body, so that a new object is created each loop iteration:

    for (var x = 0; x < (tempUserData.length); x++) {
         var UserDataEntry = {};

Leave a Comment