Creates a shallow copy of an Array object. This function is static and can be invoked without creating an instance of the object.
var cloneVar = Array.clone(array);
The array to create a shallow copy of.
Use the clone function to create a shallow copy of an Array object. A shallow copy contains only the elements of the array, whether they are reference types or value types. However, it does not contain the referenced objects. The references in the new Array object point to the same objects as in the original Array object. In contrast, a deep copy of an Array object copies the elements and everything directly or indirectly referenced by the elements.
In Mozilla Firefox version 184.108.40.206 and earlier, the Array.addRange and Array.clone functions might drop elements from the ends of large, sparse arrays.
The following code example demonstrates how to create a copy of an array using the clone function.
var a = ['a', 'b', 'c', 'd'];
var b = Array.clone(a);
// View the results: "abcd"