Operators
An operator is a special character or series of characters that perform a task in JavaScript.
Assignment Operator
The assignment operator (=
) assigns a value to a variable.
var x = 10;
Arithmetic Operators
Arithmetic operators are used to perform arithmetic on numbers:
+
addition-
subtraction*
multiplication/
division%
modulo
// Addition5 + 5;// Subtraction10 - 5;// Multiplication5 * 10;// Division10 / 5;// Modulo10 % 5;
Assignment Operators
An assignment operator assigns a value to its left operand based on the value of its right operand. Here are some of them:
+=
addition assignment-=
subtraction assignment*=
multiplication assignment/=
division assignment
let number = 100;// Both statements will add 10number = number + 10;number += 10;console.log(number);// Output: 120
Comparison Operators
==
equal to===
equal value and equal type!=
not equal!==
not equal value or not equal type>
greater than<
less than>=
greater than or equal to<=
less than or equal to?
ternary operator