Home > Web Front-end > JS Tutorial > What does !== mean in js?

What does !== mean in js?

下次还敢
Release: 2024-05-01 05:12:15
Original
1019 people have browsed it

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.

What does !== mean in js?

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>
Copy after login

Usage scenarios:

!== operator is often used when strict comparison of equality is required Cases like:

  • Make sure the values ​​of two variables are different
  • Check if the value is null or undefined
  • Compare variables of different types

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>
Copy after login

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!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template