Here you can find the source of clone()
// prot.js//w w w . j av a 2s. co m // Every being in the universe knows right from wrong. /* object extensions */ Object.prototype.clone = function() { var copy = this.constructor() for (var attr in this) { if (this.hasOwnProperty(attr)) copy[attr] = this[attr] } return copy }
Object.prototype.clone = function () { var obj = this.constructor === Array ? [] : {}; for (var e in this) { obj[e] = typeof this[e] === 'object' ? this[e].clone() : this[e]; return obj;
Object.prototype.clone = function() { var newObj = {}; for (var i in this) { if (typeof(this[i]) == 'object' || typeof(this[i]) == 'function') { newObj[i] = this[i].clone(); } else { newObj[i] = this[i]; return newObj; };
Object.prototype.clone = function () { var o = new Object(); for (var property in this) { o[property] = typeof (this[property]) == 'object' ? this[property].clone() : this[property] return o
Object.clone = function(object) { var clone = {}; Object.each(object, function(key, value) { clone[key] = value; }); return clone; };