Merge Javascript Objects and All References Pointing at Them
问题 In javascript, variables referring to objects are passed a "copy of the reference". I am struggling with this concept as it relates to merging two objects, and the effect on the references to those objects. Attempting to use underscore's extend, take the following (coffeescript) code: a = { id: 1 type: "cat" name: "Angry" } b = { id: 1 type: "dog" owner: "Bill" } c = a d = c e = b _.extend(a, b) b = a d.home = "Nashville" console.log(a) //Object {id: 1, type: "dog", name: "Angry", owner: