Created
July 18, 2017 08:31
-
-
Save jhyang12345/3c8db44266a9e86ff477f0ab69e5e7f5 to your computer and use it in GitHub Desktop.
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
document.addEventListener("DOMContentLoaded", function(event) { | |
console.log("DOM fully loaded and parsed"); | |
}); | |
function copyConstructor(obj) { | |
for(var key in obj) { | |
this[key] = obj[key]; | |
} | |
} | |
function makeObject(obj, healthObj) { | |
obj.prototype = healthObj; | |
copyConstructor.prototype = healthObj; | |
return new copyConstructor(obj); | |
} | |
var healthObj = { | |
showHealth : function() { | |
console.log(this.name); | |
}, | |
getDeeper : function() { | |
console.log(this.something.more); | |
} | |
} | |
var myHealth = makeObject({ | |
name : "나야나~~", | |
lastTime : "23:10", | |
something : {more : "deeper"} | |
}, healthObj); | |
console.log(myHealth); | |
myHealth.showHealth(); | |
myHealth.getDeeper(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment