Skip to content

Instantly share code, notes, and snippets.

@jhyang12345
Created July 18, 2017 08:31
Show Gist options
  • Save jhyang12345/3c8db44266a9e86ff477f0ab69e5e7f5 to your computer and use it in GitHub Desktop.
Save jhyang12345/3c8db44266a9e86ff477f0ab69e5e7f5 to your computer and use it in GitHub Desktop.
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