Ad
  • Custom User Avatar
  • Custom User Avatar

    "Variables" are just name tags, they can point to the same object, like in JS:

    var a = [];
    var b = a; // a and b are the same object
    a.push(1); // both a and b are [1] now
    

    If you want to work with them you need to copy every object (read: anything that's not a primitive value):

    var a = [];
    var c = a.slice(); // c is a shallow copy of a, so different object
    a.push(1); // c remains []