David Bruant wrote:
Le 05/08/2013 05:54, Brendan Eich a écrit :
David Bruant wrote:
Le 04/08/2013 00:10, Brandon Benvie a écrit :
On 8/3/2013 12:30 PM, David Bruant wrote:
That said, I recently worked on a project and I reviewed a pull request with "typeof x === 'object'" to ask to replace to 'Object(x) === x'.
On a side note, I think your version of isObject is problematic because it requires allocating an object every time the function encounters a primitive.
It's not required. That's the raw reading of the spec and that's probably what the implementations do, but it's not required. When reading "if(Object(x) === x)", the JS engine, at the time of calling "Object(x)" knows that the outcome won't be used except for its identity. It also knows that what matters isn't even the identity, but whether the identity is equal to x. In essence, the allocation isn't required per se.

Does any engine actually optimize away the wrapper?
Is this pattern used in a benchmark engines optimize against?

Not AFAIK, so I doubt any engine optimizes yet!

Filed https://bugzilla.mozilla.org/show_bug.cgi?id=901442 on the SpiderMonkey side.


Thanks,

/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to