typeof extensibility, building on my Value Objects slides from Thursday's TC39 meeting
bbenvie at mozilla.com
Sat Aug 3 15:10:51 PDT 2013
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'.
I was actually the original author of that code. =D The function was:
let type = typeof value;
return type == "object" ? value !== null : type == "function";
Which would work just fine if typeof null was "null".
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. I'd prefer avoiding the unnecessary allocation in a function
that is likely to be called very often.
More information about the es-discuss