Home >Web Front-end >JS Tutorial >What are the basic data types of JS?

What are the basic data types of JS?

王林
王林Original
2024-02-24 10:36:081294browse

What are the basic data types of JS?

The basic data types of JS are as follows: Number, String, Boolean, Null, and Undefined.

  1. Number: used to represent numbers, including integers and floating point numbers. For example:
let num1 = 10; // 整数
let num2 = 3.14; // 浮点数
  1. String: used to represent text data. Strings need to be enclosed in quotes (single or double quotes). For example:
let str1 = 'Hello'; // 使用单引号
let str2 = "World"; // 使用双引号
  1. Boolean value (Boolean): used to represent true (true) or false (false). For example:
let isTrue = true; // 真
let isFalse = false; // 假
  1. Null: used to represent an empty value. For example:
let emptyValue = null;
  1. Undefined: used to represent a variable that has not been assigned a value. For example:
let undefinedValue;

The above are the basic data types of JS and their corresponding code examples. In actual development, we often use these data types to store and operate different data.

The above is the detailed content of What are the basic data types of 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