[Discourse] Paraphrase "Type" in JS in one time
Here we see a graphic like below:
Now we use "typeof" and "instanceof" these built-in methods to inspect them.
instanceof
You can't do any of
instanceof
operation on the top row, it's special to the left coloum.
Theinstanceof
operation to left coloum will either equal to their specific type OR "Object" type.
typeof
typeof
to any item will return it's corresponding type in the top row except null, it will returnobject
. It's a buggy for 2 decades.typeof
to any item will return it'sobject
type in the left coloum exceptFunction
. it's will returnfunction
.
Need to be mentioned
Basic type : object, string, number, boolean, null, undefined. Not include
function
.
Object type: Object, String, Number, Boolean, Function, Array, Date, RegExp, Error
转载于:https://www.cnblogs.com/steadfast-JSer/articles/9073597.html