Skip to content

Instantly share code, notes, and snippets.

@raycmorgan
Forked from dylanbathurst/gist:2347074
Created April 9, 2012 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raycmorgan/2347104 to your computer and use it in GitHub Desktop.
Save raycmorgan/2347104 to your computer and use it in GitHub Desktop.
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