Javascript Object Prototype Clone
Object.prototype.clone = function() { let objClone = new Object(); for (let key in this) objClone[key] = this[key]; /*from ww w . ja v a 2 s . co m*/ return objClone; } // Lets create an object with a few properties let myOldObject = { name: "Jimmy", sayHi: function() { console.log("Hi, I'm " + this.name);}}; let myClone = document.body.clone(); myOldObject.name = "Alex"; console.log(myClone.name );