A brief analysis of the typeof operator in JavaScript

  • 2020-03-30 00:39:12
  • OfStack

If the operator of typeof is a number, string, or Boolean, the result it returns is "number, ""string," or "Boolean." for objects, arrays, or null, it returns

"Object" returns "function" for a function operand, if the operand is undefined, it returns "undefined".

Typeof returns "object" when its operand is a wrapper object such as Number, String, or Boolean, and "object" for Date and RegExp objects.

For objects that are not part of the JavaScript core language but are provided by the JavaScript embedded environment, the return value of typeof is determined by the implementation.


Related articles: