Closed cscott closed 10 years ago
Just a quick hack suggestion for your implementation of the IsObject helper. It turns out that Object(x) === x is a great way to do this test, and spec-compliant. See https://github.com/paulmillr/es6-shim/blob/86968ce03b216282052741c43cb69f2e376f35d1/es6-shim.js#L92-L96 and the contribution by @michaelficarra in https://github.com/paulmillr/es6-shim/issues/208 .
IsObject
Object(x) === x
We actually use x != null && Object(x) === x to avoid creating a new Object instance in the case where x is null or undefined, but you don't strictly need the guard.
x != null && Object(x) === x
null
undefined
Thanks, @cscott. This is a good point.
When I start working on the code here again, I'll probably make this change. In the meantime, closing.
Just a quick hack suggestion for your implementation of the
IsObject
helper. It turns out thatObject(x) === x
is a great way to do this test, and spec-compliant. See https://github.com/paulmillr/es6-shim/blob/86968ce03b216282052741c43cb69f2e376f35d1/es6-shim.js#L92-L96 and the contribution by @michaelficarra in https://github.com/paulmillr/es6-shim/issues/208 .We actually use
x != null && Object(x) === x
to avoid creating a new Object instance in the case where x isnull
orundefined
, but you don't strictly need the guard.