Reputation: 32823
As the title says it all, typeof (Array, null)
returns object
and typeof(null, Array)
returns function
.
It returns the type of the second parameter.
Why ?
Upvotes: 5
Views: 166
Reputation: 382122
Because
typeof
is an operator, not a function, so typeof(expr)
is typeof expr
, with expr
evaluated firsta,b
returns b
So
typeof (a, b)
returns typeof b
and in your case
typeof (Array, null)
is typeof null
which is "object"
typeof(null, Array)
is typeof Array
, and Array
is a function.Upvotes: 7