2010 NEWS 2010-01-06 - NEW METHOD: Uize.pairUp
The new Uize.pairUp
static method, implemented in the Uize
base class, returns an object that is the specified key and value, paired up together in the same object.
EXAMPLE
Uize.pairUp ('foo','bar'); // returns the object {foo:'bar'} Uize.pairUp (0,'zero'); // returns the object {0:'zero'} Uize.pairUp (1,true); // returns the object {1:true}
The Uize.pairUp
method is useful when an object needs to be created from a key/value pair, where the key name is either dynamically generated in an expression or is supplied via a parameter. Using the Uize.pairUp
method can collapse three statements into a single statement, as follows...
INSTEAD OF
var object = {}; object [key] = value; doSomethingWithAnObject (object);
USE...
doSomethingWithAnObject (Uize.pairUp (key,value));