copy

Copy a wrapped thing.

The function does not preserve the wrap or Type of a thing. Use dup(..) if you want a true duplicate.

This function does not generate a change.

Function

<Type>.copy([deep]])

Arguments

Argument Type Description
deep int (optional) How deep to copy the wrapped thing. Default is 1.

Return value

A new thing.

Example

This code shows an example using copy() on a wrapped thing:

set_type('Person', {
    name: 'str'
});

robot = {
    name: 'Foo',
    isHuman: false
};

foo = robot.wrap('Person').copy();

foo;  // note that only `name` is copied

Return value in JSON format

{
    "name": "Foo"
}