Namespace glow.util
Defined in: core.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Core JavaScript helpers
|
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
glow.util.apply(destination, source)
Copies properties from one object to another
All properties from 'source' will be copied onto
'destination', potentially overwriting existing properties
on 'destination'.
|
| <static> |
glow.util.extend(sub, base, additionalProperties)
Copies the prototype of one object to another
The 'subclass' can also access the 'base class' via subclass.base
|
Method Detail
<static>
{Object}
glow.util.apply(destination, source)
Copies properties from one object to another
All properties from 'source' will be copied onto
'destination', potentially overwriting existing properties
on 'destination'.
Properties from 'source's prototype chain will not be copied.
var obj = glow.util.apply({foo: "hello", bar: "world"}, {bar: "everyone"});
//results in {foo: "hello", bar: "everyone"}
- Parameters:
- {Object} destination
- Destination object
- {Object} source
- Properties of this object will be copied onto the destination
- Returns:
- {Object} The destination object.
<static>
glow.util.extend(sub, base, additionalProperties)
Copies the prototype of one object to another
The 'subclass' can also access the 'base class' via subclass.base
function MyClass(arg) {
this.prop = arg;
}
MyClass.prototype.showProp = function() {
alert(this.prop);
};
function MyOtherClass(arg) {
//call the base class's constructor
arguments.callee.base.apply(this, arguments);
}
glow.util.extend(MyOtherClass, MyClass, {
setProp: function(newProp) {
this.prop = newProp;
}
});
var test = new MyOtherClass("hello");
test.showProp(); // alerts "hello"
test.setProp("world");
test.showProp(); // alerts "world"
- Parameters:
- {Function} sub
- Class which inherits properties.
- {Function} base
- Class to inherit from.
- {Object} additionalProperties
- An object of properties and methods to add to the subclass.