The typeof operator in JavaScript returns a string according to the type of the given value: "undefined": undefined value "boolean": Boolean value "string": string value "number": numeric value "bigint" ": BigInt value "symbol": Symbol value "object": JavaScript object (including arrays, dates, and functions) "null": null value "function": function value Note: typeof NaN returns "number", while typeof [] returns "object".
The return value type of typeof
in JavaScript
typeof
The operator is used to return the type of a specified JavaScript value. Possible return values include:
true
or false
). Number.MAX_VALUE
or less than Number.MIN_VALUE
). "object":
null
value. Note:
typeof NaN
returns "number"
, even if NaN is not a valid number. typeof []
Returns "object"
, even if the array is technically an array-like object. The above is the detailed content of What are the return value types of typeof in js. For more information, please follow other related articles on the PHP Chinese website!