15.2.2 The Object constructor

2010-07-04

object new Object([value:mixed])

Create a new object.

Code: (Meta Ecma)
function Object(value){
if (value !== undefined && value !== null) {
if (typeof value == 'string') return ToObject(value);
if (typeof value == 'boolean') return ToObject(value);
if (typeof value == 'number') return ToObject(value);
// value must be an object
if (value instanceof Object || value instanceof Boolean || value instanceof String || value instanceof Number || value instanceof Array || value instanceof Date || value instanceof Error || value instanceof RegExp) { // and all other error objects
// value is a built-in type object
return value;
}
// value is a host object
return value; // implementation specific action may be taken here
}
// value is not supplied or was undefined or null
var obj = new Object;
obj.[[Prototype]] = Object.[[Prototype]]; // 15.2.4...
obj.[[Class]] = 'Object';
obj.[[Extensible]] = true;
// todo: internal methods of obj as 8.12
return obj;
}