web training room for online courses
Online Training for Asp.net MVC Web Designing Development, MS SQL, Digital Marketing

Javascript operators examples

Learn how to use operators in javscript, Assignment operator, Comparison operator, Logical operator, Bitwise operator, Arithmetic operator in Javascript.

JavaScript Assignment Operators

Operator Description Example
= assigning the right side value to variable in left side a = b, means assigning the value of b to a
+= current value + new value var a = 10; a += 5;
that means a will become a+5= 15
-= current value - new value var a = 10; a -= 5;
that means a will become a-5= 5
*= current value * new value var a = 10; a *= 5;
that means a will become a*5= 50
/= current value / new value var a = 10; a /= 5;
that means a will become a/5= 2

JavaScript Comparison Operators

Operator Description Example
== equal to, check if both equal, Returns true or false a==b, means a equal to b
!= Not equal to, check if both not equal, Returns true or false a!=b, means a not equal to b
> greater than, Returns true or false a>b, means a greater than b
>= greater than equal to, Returns true or false a>=b, means a greater than equal to b
< less than, Returns true or false a<b, means a less than b
<= less than equal to, Returns true or false a<b, means a less than equal to b

JavaScript Logical Operators

Operator Description Example
|| OR (a === 10 || b === 5) is false
&& AND (a < 10 && b >5) is true
! NOT !(a == b) is true

JavaScript Bitwise Operators

Operator Description Example
~ NOT a = ~ 5
^ XOR a = 5 ^ 1

JavaScript Arithmetic Operators
Here we use two variable (a=10, b=5) to show you the examples below.

Operator Description Example
% Modulus (division remainder) a % b :
++ Increment a = b++ :
-- Decrement
+ Addition
- Subtraction
* Multiplication
/ Division


Comment
Name Email Website
Subscribe
 
Javascript operators, Learn JavaScript Syntax

Operators in JavaScript: Assignment, Comparison, Logical, Bitwise, Arithmetic


Consulting