...

View Full Version : this clones a multi-dimensional array....found this code



BrightNail
06-26-2004, 01:19 AM
FOUND THIS SOMEWHERE - not mine...but want to post it for others since I was going crazy trying to find something that would clone multi-dimensional arrays...

keywords: clone, copy, array, multi dimensional


Array.prototype.clone = function () {
var tmp = [];
for (i in this) {
if (this[i].constructor == Array) {
tmp[i] = this[i].clone();
} else {
tmp[i] = this[i];
}
}
return tmp;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum