Udostępnij za pośrednictwem


Array.addRange Function

Copies all the elements of a specified Array object to the end of the array. This function is static and can be invoked without creating an instance of the object.

Array.addRange(array, items);

Arguments

Term

Definition

array

The array to add items to.

items

The array of items to append.

Remarks

Use the addRange function to add all the elements of one array to the end of another array. If items contains an array without any items, the target array is unchanged and no exception is thrown.

Note

In Mozilla Firefox version 2.0.0.1 and earlier, the Array.addRange and Array.clone functions might drop elements from the ends of large, sparse arrays.

Example

The following example shows how to append the elements of one array to another array by using the addRange function.

var a = ['a', 'b', 'c', 'd'];
var b = ['f', 'g','h'];
Array.addRange(a, b);
// View the results: "abcdefgh"
alert(a.toString());

See Also

Reference

Array Object

Array Type Extensions

Other Resources

Language Reference