Skip to content

Mangler.getCloner()

Robert Biro edited this page Sep 5, 2016 · 5 revisions

Returns the cloning function for an object.

Mangler.getCloner(object)

object

An object to get the cloning function for. Alternatively you can pass a type name string, as returned by Mangler.getType().

Returns

Returns a cloning function in the form of function(object), or null if object is not clonable.


Gets a cloning function for any object that's supported by Mangler.js:

var a = Mangler([1, 2, 3]);

var func = Mangler.getCloner(a);

var cloned_a = func ? func(a) : a;

The above example is identical to:

var a = Mangler([1, 2, 3]);

var cloned_a = Mangler.clone(a);

To check whether an object type is clonable:

var isClonable = !!Mangler.getCloner('Date');     // true

For supported object types and to add support for other objects, see Mangler.registerType().

Learning Mangler.js

Optional Modules

Reference

Clone this wiki locally