if (obj === Object(obj)) return 'object';

That is cut from chaijs/type-detect/blob/master/lib/type.js#L42 
<https://github.com/chaijs/type-detect/blob/master/lib/type.js#L42>.

My first guess (probably a joke):

obj === Object(obj)

is somewhat similar to

obj instanceof Object

My second guess is that it's used to distinguish between primitive value 
(created using literal) and primitive object (created using instantiation) 
such as 1 and (new Number(1)).

But typeof operator could correctly distinguish by itself:

typeof 1 === 'number'
typeof new Number(1) === 'object'

Also I feel line 41 
<https://github.com/chaijs/type-detect/blob/master/lib/type.js#L41> is 
unnecessary too:

if (obj === undefined) return 'undefined';

I don't know why would those 2 lines of code be there while

return typeof obj;

in line 43 
<https://github.com/chaijs/type-detect/blob/master/lib/type.js#L43> could 
as well be enough to substitute both.

Is there any edge case here?

May be I am missing something internal here?

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/086b3dab-91eb-4bef-8d17-3c85d4f84417%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to