9.9 ToObject

2010-05-04

Object ToObject(input) throws TypeError

Convert the input to an object.

Code: (Meta Ecma)
function ToObject(input){
if (input === undefined || input === null) throw TypeError;
if (typeof input == 'boolean') return new Boolean(input);
if (typeof input == 'string') return new String(input);
if (typeof input == 'number') return new Number(input);
return input; // must be an object...
}