Posted By

johndonahue on 02/03/10


Tagged

javascript arrays Objects clone


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

nerdfiles


JavaScript Clone Objects & Arrays


 / Published in: JavaScript
 

  1. 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}
  2.  
  3. Array.prototype.clone = function () {var a = new Array(); for (var property in this) {a[property] = typeof (this[property]) == 'object' ? this[property].clone() : this[property]} return a}

Report this snippet  

You need to login to post a comment.