Home >Web Front-end >JS Tutorial >What are the basic data types in js

What are the basic data types in js

下次还敢
下次还敢Original
2024-05-07 21:48:19959browse

The basic data types of JavaScript are: numbers, strings, Boolean values, undefined, null, objects and Symbol. Among them, numbers represent numerical values, strings represent character sequences, Boolean values ​​represent true or false, undefined represents uninitialized or non-existent variables, null represents empty values, objects are the base classes of complex data structures, and Symbol represents the only immutable value. .

What are the basic data types in js

Basic data types of JavaScript

JavaScript provides a variety of basic data types for storage and representation Different types of values. These data types include:

1. Number

  • represents an integer or floating point number.
  • can be expressed in decimal, hexadecimal or octal.
  • For example: 10, 3.1415, 0xFF

2. String

  • represents a string of Unicode characters.
  • Can be expressed using single quotes ('), double quotes (") or backticks (`).
  • For example: 'Hello World', "JavaScript", `$ The age of {name} is ${age}

#3. Boolean value

    represents true or false #.
  • ## is used to represent logical conditions.
  • For example: true, false
  • ##4. undefined

## represents An uninitialized or non-existent variable.

For example: let x; console.log(x); // Output undefined
  • ##5. null

Indicates a null value. Used when the value of a variable is unknown or empty. For example: let y = null;

  • 6. Object
  • The base class for all other JavaScript data types

Used to represent complex data structures such as arrays, functions, and Object. For example: array [1, 2, 3], function function myFunc() {}, object { name: 'John Doe' }

  • ##7. Symbol
  • ##Introduced since ES2015.
  • is used to represent unique and immutable values.

is mainly used for object properties to avoid property names. Conflict. For example: const mySymbol = Symbol('mySymbol');

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

    Statement:
    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