Class 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
Constructor Summary |
IWClonable()
Using this constructor makes a class clonable.
|
Method Summary
|
Object
|
clone()
Overwrite this method to clone the object.
The default implemenation calls the default constructor (without arguments), copies all properties and clones properties which .
|
IWClonable
IWClonable()
Using this constructor makes a class clonable.
clone
Object 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 .
Source-Code Copyright 2007-2016 infoware GmbH - Documentation generated on Tue Nov 29 2022 14:20:15 GMT+0100 (MEZ)