Duplicate()

Returns a new duplicated version of the given object, removing all references to the old one

Duplicate( object=any, deepCopy=boolean );

Returns: any

Argument Description Default
object
any, required

Name of a variable to duplicate

Alias: variable_name, obj

deepCopy
boolean, optional

If set to true (default) the child elements are also cloned.

If false, child elements retain a reference to their corresponding element in the original object.

Note: deeply cloned elements that are not native Lucee objects (i.e. Java objects) may change data type when they can be converted to a native CFML object.

true

Examples

person = { first = "Babe", last = "Ruth"};
dump(person); // Babe Ruth
clone = duplicate(person);
dump(clone); // Babe Ruth
person.last = "Smith";
dump(person); // Babe Smith
dump(clone); // Babe Ruth

See also