Simple javascript prototype function to make a deep copy of an array.

1
2
3
4
5
6
7
8
9
Array.prototype.copy = function()
{
  var copy = [];
  for (var i=0; i<this.length; i++)
  {
    copy[i] = (typeof this[i].copy != 'undefined') ? this[i].copy() : this[i];
  }
  return copy;
}