Skip to content

Instantly share code, notes, and snippets.

@chuck0523
Created August 7, 2015 21:13
Show Gist options
  • Save chuck0523/8386c7e93c9d4d2942ac to your computer and use it in GitHub Desktop.
Save chuck0523/8386c7e93c9d4d2942ac to your computer and use it in GitHub Desktop.
var obj = {
mon : 0,
tue : 1,
wed : 2,
thu : undefined,
time : {
morning : "5-11",
night : "19-22"
}
}
if (typeof Object.create !== 'function') {
Object.create = function (o) {
var F = function() {};
F.prototype = o;
return new F();
};
}
var another_obj = Object.create(obj);
obj.fri = 4;
// another_objを宣言した時にはまだfriはなかったが、参照できる
console.log(another_obj.fri); //4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment