Namespace lib
Holds methods and properties necessary throughout the entire
application.
Defined in: lib.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
<static> |
lib.extend(overwrite, destination, source)
This function extends objects.
|
Method Detail
<static>
lib.extend(overwrite, destination, source)
This function extends objects.
var obj1 = {a: 'a1', b: 'b1', d: 'd1'}, obj2 = {a: 'a2', b: 'b2', c: 'c2'}; lib.extend(obj1, obj2);
// Now obj1.c == 'c2', while obj1.a, obj1.b // and obj1.d remain the same. // Iflib.extend(true, obj1, obj2)
is // called, then obj1.a, obj1.b, obj1.c // become all the same as in obj2.
var obj1 = {a: 'a1', b: 'b1', extend: lib.extend};
obj1.extend({c: 'c1', d: 'd1'});
// In this case the destination object which is to be extend is
// obj1.
- Parameters:
- {Boolean} overwrite Optional, Default: false
- If the first argument is a boolean, then it will be considered as a boolean flag for overwriting (or not) any existing methods and properties in the destination object. Thus, any method and property from the source object will take over those in the destination. The argument is optional, and if it's omitted, then no method/property will be overwritten.
- {Object} destination Optional, Default: this
- The second argument is the optional destination object: the object which will be extended. By default, the this object will be extended.
- {Object} source
- The third argument must provide list of methods and properties which will be added to the destination object.