I can't find the relevant documentation, but it appears that the Object
function either returns a new object that wraps the passed in value or returns the argument if it's already an object; otherwise, the ===
test would always return false.
Object(5) === 5 // false, Object(5) creates Number object
Object(null) === null // false, Object(null) creates an empty object
var foo = { prop: 'value' };
Object(foo) === foo // true!? Argument is not wrapped
It appears that this behavior works to test if a value is an object.
Update
It appears that this is in the spec:
When the Object function is called with no arguments or with one argument value, the following steps are taken:
1. If value is null, undefined or not supplied, create and return a new Object object exactly as if the standard built-in Object constructor had been called with the same arguments (15.2.2.1).
2. Return ToObject(value).
And ToObject's "result is the input object" is also defined in the spec.