The !== operator in JavaScript is a strict inequality operator, used to compare whether two values are equal. This operator takes into account type differences and is therefore more strict than the relaxed equality operator (==). Returns true if the two values are of different types or have different values; otherwise, returns false.
The meaning of the !== operator in JavaScript
The !== operator in JavaScript is strictly not The equal operator is used to compare two values to see if they are not equal.
Meaning:
!== operator compares two values. If the two value types are different or have different values, it returns true; otherwise, it returns false . Unlike the == operator (relaxed equality operator), it does no type conversion and is therefore more strict.
Syntax:
<code>variable1 !== variable2</code>
Usage scenarios:
!== operator is often used when strict comparison of equality is required Cases like:
Example:
<code>const num1 = 1; const num2 = "1"; console.log(num1 !== num2); // true // 即使值相同,但类型不同 const str1 = "Hello"; const str2 = "World"; console.log(str1 !== str2); // true // 两个字符串值不同 const obj1 = {}; const obj2 = {}; console.log(obj1 !== obj2); // true // 两个对象即使值相同,但引用不同 const nullValue = null; const undefinedValue = undefined; console.log(nullValue !== undefinedValue); // true // 严格比较这两个特殊值</code>
The above is the detailed content of What does !== mean in js?. For more information, please follow other related articles on the PHP Chinese website!