Home > Web Front-end > JS Tutorial > How to enter the not equal symbol in js

How to enter the not equal symbol in js

下次还敢
Release: 2024-05-10 04:21:17
Original
546 people have browsed it

The inequality operator is represented as != in JavaScript. It is used to compare whether two values ​​are not the same, and returns true if they are different, otherwise it returns false. It is different from the strict inequality operator (!==), which also compares value types.

How to enter the not equal symbol in js

How to enter the inequality symbol

in JS?

In JavaScript, the inequality operator is !=.

Purpose

The inequality operator is used to compare whether two values ​​are different. The operator returns true if the two values ​​are not the same, and false if they are the same.

Expression syntax

<code>expression1 != expression2</code>
Copy after login

where expression1 and expression2 are the values ​​to be compared.

Example

<code>console.log(1 != 2); // 输出:true
console.log("foo" != "bar"); // 输出:true
console.log(true != false); // 输出:true</code>
Copy after login

Note

Please note that the inequality operator (!= ) is different from the strict inequality operator (!==). The strict inequality operator compares not only values, but also types.

For example:

<code>console.log("1" != 1); // 输出:true
console.log("1" !== 1); // 输出:false</code>
Copy after login

In the first example, != returns true because the string "1" and the number 1 have different values . In the second example, !== returns false because they have the same value and type.

The above is the detailed content of How to enter the not equal symbol 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