Java script operators

    Operators are used to perform mathematical, logical operations on variables. In javascript,it has many categories.

They are listed below.

  • 1.       Arithmetic operators
  • 2.       Logical operators
  • 3.       Bitwise operators
  • 4.       comparison operators
  • 5.       Assignment operators
  • 6.       Others.

 

1.       1. Arithmetic operators:

    This is basic operator  which is used to perform arithmetic operations like addition, subtraction and so on.

Operator

Meaning

Usage

+

Addition

a+b ,a+50

-

Subtraction

a-b, a-10

*

Multiplication

a*b

/

Division

a/b

%

Modulation

a%b

 2.       logical operators:

    Logical operators involve with three different types of logic. It checks between two variables by three conditions.

Operator

Meaning

Usage

&&

Logical AND

a &&b

||

Logical OR

a|| b

!

Logical NOT

!a

3.      Bitwise operators:

If you want to perform bitwise operations on variables, use the below operators.

Bitwise Operators

Meaning

Usage

&

Bitwise AND

a &b

|

Bitwise OR

a| b

^

Bitwise XOR

a^b

~

Bitwise NOT

~a

<< 

Left shift

a<<2

>> 

Right shift

a>>2

>>> 

Right shift with zero

a>>>2


4.     4.  Comparison Operators:

When you want to compare the values of the variables,use these operators.

Operator

Meaning

Usage

> 

Greater than

a>b

< 

Less than

a<b

>=

Greater than or equal to

a>=b

<=

Less than or equal to

a<=b

==

Equal to

a==b

!=

Not equal to

a!=b

 

5.Assignment operators:

        Sometimes,we need to assign values to variables. These variables are called assignment operators.

 

Operator

Meaning

Usage

=

Equal

A=10

+=

Add and assign the value

a+=14

-=

Subtract and assign the value

a-=5

*=

Multiply and assign the value

a*=4

/=

Divide and assign the value

a/=56

%=

Modulo operation and assign the value

a%=6

 6.Others:

   As java is a object orient programming language, it deals with some more special operators listed below.

Operator

Meaning

(?=)

Conditional operator

,

Comma operator

Delete

Removes a property of an object

In

Checks an object’s property

Instanceof

Finds the instance of the object

typeof

Gives the type of object

New

Creates an object

Yield

It gives the generator’s value

Void

Nothing is returned as output


These are the operators used in java script. 

No comments:

Post a Comment