Home > Web Front-end > JS Tutorial > Comparison of == and === operators in JS_Basic knowledge

Comparison of == and === operators in JS_Basic knowledge

WBOY
Release: 2016-05-16 18:55:16
Original
1326 people have browsed it
=== operator:
If the two value types are different, return false
If both values ​​are of type number and have the same value, return true
If both values ​​are is string, and the String contents of the two values ​​are the same, return true
If both values ​​are true or both false, return true
If both values ​​point to the same Object, Arraya or function, return true
If both values ​​are null or both undefined, return true
== operator:
If the two values ​​have the same type, === comparison will be performed. Returns the comparison value of ===
It is also possible to return true if the two values ​​do not have the same type
If one value is null and the other is undefined, return true
If one value is a string and the other is number, the string will be converted into a number and then compared
If a value is true, it will be converted into 1 before comparison, and false will be converted into 0
If one value is an Object and the other is a number or string, The Object will be converted into the original type using valueOf() or toString() and then compared.
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