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和所有值包括自己都不相等。
“===”
100 === "100" // false 1 === true // false NaN === NaN // false null === undefined // false 'abc' === "abc" // true false === false // true null === null // true undefined === undefined // true
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!