Loading
Operators-tutorial
JavaScript operators are special symbols used to perform operations on values and variables (called operands).
They help us calculate values, compare data, assign values, and even work with bits


Example:

var add = 10 + 10; // add is 20

JavaScript supports different categories of operators



Types of Operators in JavaScript

  • Arithmetic Operators
  • Comparison (Relational) Operators
  • Bitwise Operators
  • Logical Operators
  • Assignment Operators
  • Special Operators



Arithmetic Operators

Used to do mathematical calculations like addition, subtraction, multiplication etc.


Example:

var x = 10;
var y = 3;
var sum = x + y;      // sum is 13
var product = x * y;  // product is 30



Comparison Operators

Used to compare two values and return a boolean (true or false).


Example:

var a = 5;
var b = "5";
a == b;    // true (loose equality, compares only value)
a === b;   // false (strict equality, compares value and type)



Bitwise Operators

Used to perform bit-level operations on binary representations of numbers.


Example:

var a = 5; // binary: 0101
var b = 3; // binary: 0011
var result = a & b; // 0001 (Decimal 1)



Logical Operators

Used to combine multiple conditions or boolean expressions.


Example:

var isTrue = true;
var isFalse = false;
var result = isTrue && isFalse; // result is false



Assignment Operators 

Used to assign values to varibales.


Example:

var a = 5;
a += 3; // a becomes 8 (same as a = a + 3)