Home > Web Front-end > JS Tutorial > body text

What are the return value types of typeof in js

下次还敢
Release: 2024-05-07 18:57:15
Original
934 people have browsed it

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".

What are the return value types of typeof in js

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:

  • "undefined": Indicates that the value is undefined.
  • "boolean": Indicates a Boolean value (true or false).
  • "string": Represents a string value.
  • "number": Represents a numeric value (integer or floating point number).
  • "bigint": Represents a BigInt value (an integer greater than Number.MAX_VALUE or less than Number.MIN_VALUE).
  • "symbol": Represents the Symbol value.
  • "object":

    • "null": A well-defined null value.
    • JavaScript objects (including arrays, dates, functions, and maps).
  • "function": Indicates the function 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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!