Last active
March 15, 2016 05:49
-
-
Save maousan/79397fba71c9839d1b66 to your computer and use it in GitHub Desktop.
beget
This file contains hidden or 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 = { | |
| name: "maou" | |
| }; | |
| Object.beget = function(o) { | |
| var F = function() {}; | |
| F.prototype = o; | |
| return new F(); | |
| } | |
| var o = Object.beget(obj); | |
| console.log(o.name); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment