I am not sure what's going on with this, probably I am doing something wrong, but to be honest, I cannot see what's the point. Just take a look at this code and see what happens:
var object = {
one: "one",
two: "two"
};
var object2 = {}
object2 = object;
object["three"] = "what?"
console.log(object2);
The output for the object2 should be {one: "one", "two": two"}, however it returns {one: "one", "two": two", "three": "what?"}
So why is this happening? I am not modifying object2, but it gets updated after the push of new value. How can I solve this? I just want to keep the object2 like before. Thanks