JavaScript Deep Array Clone

June 10, 2012

I had a need to deep clone an array in JavaScript. This meant I needed a new array, pointing to individual objects that were themselves clones - the new array had no direct references to elements in the source array.

This can be done in jQuery using the extend function:

var lClone = $.extend(true, [], lSource);

References

http://stackoverflow.com/questions/565430/deep-copying-an-array-using-jquery