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

What is the difference between '==' and '===' in js

王林
Release: 2020-07-13 17:06:12
forward
2862 people have browsed it

What is the difference between '==' and '===' in js

The difference is as follows:

(recommended learning: js tutorial)

== means equal, === means constant etc.;

== only compares content, while === compares both content and data types.

Test code:

“==”

100 == "100"            // true
1 == true               // true
null == null            // true
undefined == undefined  // true
null == undefined       // true
true == "20"            // false
"1" == "01"             // false,此处等号两边值得类型相同,不要再转换类型了!!
NaN == NaN              // false,NaN和所有值包括自己都不相等。
Copy after login

“===”

100 === "100"            // false
1 === true               // false
NaN === NaN              // false
null === undefined       // false
'abc' === "abc"          // true
false === false          // true
null === null            // true
undefined === undefined  // true
Copy after login

The above is the detailed content of What is the difference between '==' and '===' in js. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
js
source:csdn.net
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!