Om3ga
Om3ga

Reputation: 32823

typeof (Array, null) returns object and typeof(null, Array) returns function

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

Answers (1)

Denys Séguret
Denys Séguret

Reputation: 382122

Because

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

Related Questions