Introduction To Operators in JavaScript
1→ Arithmetic Operators
2→ Comparison Operators
3→ Logical Operators
4→ Assignment Operators
5→ Condition Operators
Arithmetic Operators :
Operators Description Example
+ Addition var c = a + b;
- Subtraction var c = a - b;
* Multiplication var c = a * b;
/ Division var c = a / b;
% Modulus var c = a % b;
++ Increment var c = ++a;
– Decrement var c = -- a;
Examples on Arithmetic Operator :
Addition Example:-
Subtraction Example:-
Multiplication Example:-
Division Example:-
Modulus Example:-
Increment Example:-
12
Decrement Example:-
1→ Arithmetic Operators
2→ Comparison Operators
3→ Logical Operators
4→ Assignment Operators
5→ Condition Operators
Operators Description Example
+ Addition var c = a + b;
- Subtraction var c = a - b;
* Multiplication var c = a * b;
/ Division var c = a / b;
% Modulus var c = a % b;
++ Increment var c = ++a;
– Decrement var c = -- a;
Examples on Arithmetic Operator :
Addition Example:-
<html> <head> <body> <script > var b = 10,c = 15; var a = b + c; document.write(a); </script> </body> </head> </html>Output : 25
Subtraction Example:-
<html> <head> <body> <script > var b = 10,c = 5; var a = b - c; document.write(a); </script> </body> </head> </html>Output : 5
Multiplication Example:-
<html> <head> <body> <script > var b = 2,c = 3; var a = b * c; document.write(a); </script> </body> </head> </html>Output : 6
Division Example:-
<html> <head> <body> <script > var b = 10,c = 5; var a = b / c; document.write(a); </script> </body> </head> </html>Output : 2
Modulus Example:-
<html> <head> <body> <script > var b = 10,c = 5; var a = b % c; document.write(a); </script> </body> </head> </html>Output : 0
Increment Example:-
<html> <head> </head> <body> <script > var b = 10,c = 5; var a = ++b;//pre-increment b++;//post-increment var e =b; document.write(a); document.write('<br>'); //using HTML code document.write(e); </script> </body> </html>Output : 11
12
Decrement Example:-
<html> <head> </head> <body> <script > var b = 10,; var a = --b; document.write(a); </script> </body> </html>Output : 9
JavaScript Introduction Part 1 : Checkout : Part 1
JavaScript Introduction Part 2 : Checkout : Part 2
JavaScript Introduction Part 3 : Checkout : Part 3
JavaScript Introduction Part 2 : Checkout : Part 2
JavaScript Introduction Part 3 : Checkout : Part 3
Konakalla Premsai I love to make things simple :) |
||||