Skip to content

Instantly share code, notes, and snippets.

@yurydelendik
Created October 24, 2012 00:37
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 yurydelendik/3943011 to your computer and use it in GitHub Desktop.
Save yurydelendik/3943011 to your computer and use it in GitHub Desktop.
Weird object creation
function p(t) {
for (var i in t) console.log(t[i]);
}
var obj1 = Object.create(null);
obj1[1] = "2";
obj1[3] = "4";
var obj2 = Object.create(null);
obj2.__proto__ = obj1;
p(obj1);
p(obj2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment