Object.clone
Object.clone
Function
Returns a deep copy of the object.
Syntax
object.clone()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| Object | Returns the new object value. |
Return object fields
The returned object contains all field names of the original object. Variable containers such as arrays, objects, and class instances will be copied recursively; non-ordinary containers such as functions, regular expressions, dates, and standard library objects maintain the original runtime semantics.
Example
user = {profile: {name: 'BT'}} result = user.clone() result.profile.name = 'New' // Output: BT echo(user.profile.name)
Notes
- clone does not modify the original object.