Duplicate a wrapped thing.

The function preserves both the wrap and Type of a thing. Use copy(..) if you want a new plain thing.

This function does not generate a change.




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

Return value

A new wrapped thing.


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

set_type('Person', {
    name: 'str'

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

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

foo.unwrap();  // foo is still wrapped, the underlying `robot` is being duplicated.

Return value in JSON format

    "name": "Foo",
    "isHuman": false