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

How to enter the not equal symbol in js

下次还敢
下次还敢Original
2024-05-10 04:21:17489browse

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>

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>

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>

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!

Statement:
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
Previous article:What is recursion in jsNext article:What is recursion in js