-
-
Save raycmorgan/2347104 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var objOne = {}; | |
var objTwo = {}; | |
objOne.foo = {}; | |
objOne.foo.bar = 100; | |
objTwo = objOne; | |
objTwo.foo.bar = 200; | |
console.log(objOne); // 200 | |
/////// | |
var objOne = {}; | |
var objTwo = {}; | |
objOne.foo = {}; | |
objOne.foo.bar = 100; | |
objTwo.foo = { | |
bar: 200 | |
}; | |
console.log(objOne); // 100 | |
console.log(objTwo); // 200 | |
//////// | |
function createObj() { | |
return { foo: 0 }; | |
} | |
var objOne = createObj(); | |
objOne.foo.bar = 100; | |
var objTwo = createObj(); | |
objTwo.foo.bar = 200; | |
////// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment