Class: IWClonable

IWClonable

A base class for clonable objects. This class provides the method clone() which clones all properties from the prototype and object itself. Example:
function MyClass(argument)
{
	IWClonable.call(this);
 this.property = argument;
};

MyClass.prototype = new IWClonable();
MyClass.prototype.constructor = MyClass; // otherwise the constructor will be IWClonable

MyClass.prototype.getProperty = function()
{
	return this.property;
};

var object = new MyClass(1337);
var clone = object.clone();

object.property = 0;

console.log(object.getProperty()); // will return 0, i.e. the modified value
console.log(clone.getProperty()); // will return 1337, i.e. the original and cloned value

new IWClonable()

Using this constructor makes a class clonable.
Since:
  • 0.74.2

Methods


clone()

Overwrite this method to clone the object. The method returns a new instance of the object. The default implemenation calls the default constructor (without arguments), copies all properties and clones properties which .
Returns:
Type
Object