jorendorff / js-loaders

Pseudoimplementation of the proposed ES6 module loaders.
54 stars 7 forks source link

ToObject tweak. #101

Closed cscott closed 10 years ago

cscott commented 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 .

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.

jorendorff commented 10 years ago

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.