Array.clone
Array.clone
Function
Returns a deep copy of the array.
Syntax
array.clone()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| Array | Returns the new array value. |
Example
items = [{name: 'A'}] result = items.clone() result[0].name = 'B' // Output: A echo(items[0].name)
Notes
- Clone will recursively copy mutable containers such as arrays, objects, and class instances.
- Non-ordinary containers such as functions, regular expressions, dates and standard library objects maintain the original runtime semantics.