UIZE JavaScript Framework

2012 NEWS 2012-03-24 - New Uize.canExtend Method

The new Uize.canExtend static method, implemented in the Uize base module, returns a boolean, indicating whether or not the specified value can be extended with custom properties.

SYNTAX

canExtendBOOL = Uize.canExtend (valueANYTYPE);

A value is considered extendable if it is of type "function", or of type "object" and non-null. Function instances can be extended with custom propeerties, and non-null objects can also be extended with custom properties because this encompasses plain objects, instances of custom object classes, and list objects like instances of JavaScript's built-in Array object. Values that are not considered extendable are nully values like null and undefined, and values for JavaScript primitives, like string values, number values, and boolean values.

EXAMPLES

Uize.canExtend ({foo:'bar'});         // returns true
Uize.canExtend (['foo','bar']);       // returns true
Uize.canExtend (function () {});      // returns true
Uize.canExtend (new String ('foo'));  // returns true
Uize.canExtend (new Boolean (true));  // returns true
Uize.canExtend (new Number (42));     // returns true
Uize.canExtend (Uize.Widget);         // returns true
Uize.canExtend (Uize.Widget ());      // returns true

Uize.canExtend ('foo');               // returns false
Uize.canExtend (true);                // returns false
Uize.canExtend (42);                  // returns false
Uize.canExtend (null);                // returns false
Uize.canExtend (undefined);           // returns false