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

What are the types of data types in js

下次还敢
Release: 2024-05-01 05:24:14
Original
779 people have browsed it

There are 12 data types in JavaScript: 6 primitive types (undefined, null, boolean, number, string, BigInt, Symbol) and 3 reference types (object, array, function). In addition, there are 4 special values ​​(NaN, Infinity, -Infinity) and 3 special data types (void, const, let).

What are the types of data types in js

Data types in JavaScript

JavaScript is a dynamically typed language, which means that variables can be when changing its data type. There are the following data types in JavaScript:

Primitive data types

  • undefined: represents an uninitialized variable or property.
  • null: indicates a value that clearly does not exist.
  • boolean: represents true or false.
  • number: represents a number.
  • string: represents a string.
  • BigInt: Represents an integer larger than the Number data type.
  • Symbol: represents a unique and immutable value.

Reference data type

  • object: Represents a non-primitive value containing a key-value pair.
  • array: represents an ordered collection containing elements.
  • function: represents a code block that can be called.
  • Date: represents a date and time.

Special data types

  • NaN: represents a non-numeric value.
  • Infinity: represents positive infinity.
  • -Infinity: represents negative infinity.

Others

In addition to these data types, there are the following special values:

  • void:Indicates a function call that does not return any value.
  • const: represents a constant whose value cannot be changed.
  • let: represents a variable whose value can be changed within the code block.
  • var: represents a variable whose value can be changed in the global or local scope.

The above is the detailed content of What are the types of data types in js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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!