wrapReflectors: a Boolean value that determines if objects reflected from C++, such as DOM objects, should be cloned. If omitted the default value is false. See Cloning objects that contain DOM elements below.

Returns

A reference to the cloned object.

Example

This add-on script creates an object, clones it into the content window and makes it a property of the content window global:

Cloning objects that have functions

If the object to be cloned contains functions, you must pass the {cloneFunctions:true} flag or you'll get an error. If you do pass this flag, then functions in the object are cloned using the same mechanism as that used in Components.utils.exportFunction:

Cloning objects that contain DOM elements

By default, if the object you clone contains objects that are reflected from C++, such as DOM elements, the cloning operation will fail with an error. If you pass the {wrapReflectors:true} flag, then the object you clone is allowed to contain these objects: