Home >Web Front-end >JS Tutorial >jquery determines whether values ​​are equal

jquery determines whether values ​​are equal

藏色散人
藏色散人Original
2021-02-03 11:13:054446browse

Jquery method to determine whether values ​​are equal: first create a code sample file; then define several different variables; finally use the comparison operator "==" or "===" to determine whether the variable values ​​​​are equal That’s it.

jquery determines whether values ​​are equal

The operating environment of this article: windows7 system, jquery1.2.6 version, Dell G3 computer.

jquery can use == or === to judge:

1. == is to judge whether the values ​​are equal. If the data types are different, convert the data type first and then judge;

2. === is similar to ==. It also determines whether the values ​​are equal. However, if you use ===, if the data types are different and the values ​​are the same, they will not be equal.

Example:

var a = "1"; //字符串1
var b = 1; //数值1
var c = true; //布尔值1
var d = "1";
if (a==b && a==c && a==d) {console.log('equality');} //输出equality
if (a===b || a===c) { //输出not identity
console.log('identity');
}
else {
console.log('not identity');
}
if (a===d) {console.log('identity');} //输出identity

Recommended: "jquery video tutorial"

The above is the detailed content of jquery determines whether values ​​are equal. 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:How to write css in reactNext article:How to write css in react