Home > Web Front-end > JS Tutorial > Basic JavaScript knowledge summary (3) comparison operators and logical operators

Basic JavaScript knowledge summary (3) comparison operators and logical operators

php中世界最好的语言
Release: 2018-03-10 11:50:18
Original
1573 people have browsed it

This time I will bring you a basic knowledge summary of JavaScript. There are a total of eleven knowledge points. Basic JavaScript knowledge summary (3)Comparison operators, Logical operator, the following is a practical case, let’s take a look.

Write at the front

js (2) mentioned simple addition, subtraction, multiplication and division. Now let’s talk about the other two operators

Comparison operators

“>”、“<”、“==”、“>=”、“<=”、“!=”
Copy after login

The result of the comparison is a boolean value

Logical operator

“&&”、“||”、“!”
Copy after login

The result of the operation is the real value

The value that is considered false

undefined、null、NaN、""、0、false
Copy after login

Calculation Operator

var a = 10,
    b = 20,
    c;
    c = a < b;//true
    c = a > b;//false
    c = "a" > "b"//false,比较的ascll码值
    c = a == b// false
    c = a != b//false
    c = NaN == NaN//false,NaN不等于任何数;
Copy after login

Logical operator

//Logical AND &&var a = 1 && 2//Print out a-->2//Logical OR||var a = 1 || 3;//Print out a-->1//Logical not! Convert to Boolean value and invert var a = !123;//false;

Logical AND&& Let’s look at the first one first The result of converting an expression to a Boolean value. If it is true, then it will look at the result of converting the second expression to a Boolean value. Then if there are only two expressions, it will only look at the second one. Expression, you can return the value of the expression, a short-circuit statement;

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Related reading:

Summary of basic JavaScript knowledge (2) Introduction, variables, value types, operators

Summary of basic JavaScript knowledge (1)

The above is the detailed content of Basic JavaScript knowledge summary (3) comparison operators and logical operators. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template