/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Object.prototype.clone = function() { var newObj = (this instanceof Array) ? [] : {}; for (i in this) { if (i == 'clone') continue; if (this[i] && typeof this[i] == "object") { newObj[i] = this[i].clone(); } else newObj[i] = this[i] } return newObj; };
URL: http://my.opera.com/GreyWyvern/blog/show.dml/1725165