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:
```js
function isObject(value){
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.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss