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

What are the basic data types of JS?

王林
Release: 2024-02-24 10:36:08
Original
1176 people have browsed it

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; // 浮点数
Copy after login
  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"; // 使用双引号
Copy after login
  1. Boolean value (Boolean): used to represent true (true) or false (false). For example:
let isTrue = true; // 真
let isFalse = false; // 假
Copy after login
  1. Null: used to represent an empty value. For example:
let emptyValue = null;
Copy after login
  1. Undefined: used to represent a variable that has not been assigned a value. For example:
let undefinedValue;
Copy after login

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!

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!