Operators in JavaScript

Source: Internet
Author: User
Tags arithmetic operators logical operators

operator to operate on one or more variables or values (operands) and return a new value

Depending on the operation performed, the operators can be divided into the following categories:

(1) Arithmetic operators

(2) Comparison operators

Operator

Speak clearly

Show Example

==

Equals.

Returns true if the two operands are equal.

A = = B

!=

Not equal to.

Returns true if the two operands are not equal.

Var2! = 5

>

Greater than.

Returns true if the left operand is greater than the right operand.

Var1 > Var2

<

Less than.

Returns true if the left operand is less than the right operand.

Var2 < var1

<=

is less than or equal to.

Returns true if the left operand is less than or equal to the operand to the right.

VAR2 <= 4

Var2 <= var1

>=

Greater than or equal. Returns true if the left operand is greater than or equal to the right operand.

VAR1 >= 5

Var1 >= var2

(3) Logical operators

Operator

Value

Speak clearly

and (&&)

Expr1 && EXPR2

It is only when expr1 and expr2 are true that they return true. Otherwise, returns false.

or (| |)

Expr1 | | Expr2

Returns true if one of the expressions is true, or two expressions are true. Otherwise, returns false.

Non - (!)

!expr

If the expression is true, False is returned. If False, returns TRUE.

Operators in JavaScript

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.