Home > Web Front-end > Front-end Q&A > What is the usage of '===' in javascript

What is the usage of '===' in javascript

青灯夜游
Release: 2023-01-05 16:11:33
Original
4154 people have browsed it

"===" is a comparison operator built into JavaScript. It is used to determine whether a variable or value is absolutely equal in a logical statement, that is, the value and type are equal; the "===" operator will First compare whether the data types of the variables on both sides are equal, and then compare whether the values ​​​​of the variables on both sides are equal; only when the data types and values ​​​​are equal, true will be returned.

What is the usage of '===' in javascript

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

javascript === operator

"===" is a comparison operator built into JavaScript, used in logical statements. To determine whether variables or values ​​are equal; the return value is true or false.

"===" means identity, that is, absolute equality (both value and type are equal).

The "===" operator first compares whether the data types of the variables on both sides are equal, and then compares whether the values ​​​​of the variables on both sides are equal; only when the data types and values ​​​​are equal, the two variables are equal.

Example:

var x=5;
x==="5";  // 返回 false
x===5;   // 返回 true
Copy after login

What is the usage of === in javascript

[Recommended learning: javascript advanced tutorial

The above is the detailed content of What is the usage of '===' in javascript. 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