Going on from this question here: Checking for undefined
I wanted to know if an object was an Array
, now I need to test to see if an Object is specifically an Object
and not just a subclass of an Object
Because at the moment an Array
would return true if checked to see if it is an instance of an Object
. Are there any other types that would evaluate to true?
EXTRA INFO
I have found that if you call toString
on an Array
that has one string element it resolves to that string element and not "[object Array]"
so you need to be careful of that. For example:
["str1", "str2"].toString() === "[object Array]"
but
["str1"].toString() === "str1"