Hi all today I will be sharing a small intro regarding the different operators in JavaScript. There are mainly two different groups of operators:
1.Arithmetic Operators: These are operators used to perform the basic mathematical calculations such as:
a)Addition(+): This adds two integers and gives the output.
let d=23;
let g=42;
const h= d+g;
console.log(h);
Output//65
b)Subtraction(-):This subtracts two integers and gives the output.
let d=33;
let g=10;
const h= d-g;
console.log(h);
Output//23
c)Multiplication(*):This multiplies two integers and gives the output.
let d=33;
let g=10;
const h= d*g;
console.log(h);
Output//330
d)Division:This divides two integers and gives the quotient as the output.
let d=33;
let g=10;
const h= d/g;
console.log(h);
Output//3
e)Modulus(%):This divides two integers and gives the reminder as the output.
let d=15;
let g=2;
const h= d%g;
console.log(h);
Output//1
Next there are Equality Operators:
- Loose Equality (==)
- Compares values after converting them to a common type.
- Can lead to unexpected results due to type coercion.
2.Strict Equality (===)
- Compares both value and type.
- No type conversion—more predictable and safer.
- Inequality Operators
- != is the loose version (like ==)
- !== is the strict version (like ===)
Apart from these there are Comparison Operators which compare two values and provides the output.
1.Greater than (>)
2.Lesser than(<)
3.Greater than equal to (>=)
4.Lesser than equal to (<=)
Top comments (0)