
Operators & Expressions in JavaScript
What are Operators in JavaScript? Operators are symbols used to perform operations on values and variables. Types of Operators in JavaScript 1. Arithmetic Operators: Used to perform mathematical calculations Operators List: + → Addition - → Subtraction * → Multiplication / → Division % → Modulus let a = 10 ; let b = 5 ; console . log ( a + b ); // 15 console . log ( a - b ); // 5 console . log ( a * b ); // 50 console . log ( a / b ); // 2 console . log ( a % b ); // 0 2. Assignment Operators: Used to assign values to variables let x = 10 ; x += 5 ; // x = x + 5 → 15 x -= 2 ; // x = x - 2 → 13 = += -= *= /= 3. Comparison Operators: Used to compare two values (returns true/false) console . log ( 10 > 5 ); // true console . log ( 10 == " 10 " ); // true console . log ( 10 === " 10 " ); // false == → Equal (value only) === → Strict Equal (value + type) != → Not equal > < >= <= 4. Logical Operators: Used to combine conditions let age = 25 ; console . log ( age > 18 && age < 30 ); // true c
Continue reading on Dev.to Tutorial
Opens in a new tab



