Created
August 7, 2015 21:13
-
-
Save chuck0523/8386c7e93c9d4d2942ac 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 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