DEV Community

Ranjani R
Ranjani R

Posted on

JAVASCRIPT OPERATORS

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

Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Next there are Equality Operators:

  1. Loose Equality (==)
  2. Compares values after converting them to a common type.
  3. Can lead to unexpected results due to type coercion.

2.Strict Equality (===)

  • Compares both value and type.
  • No type conversion—more predictable and safer.
  1. Inequality Operators
  2. != is the loose version (like ==)
  3. !== 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)