JavaScript Operators
JavaScript Operators
Examples:
JavaScript Assignment
Assignment Examples
let x = 10;
let x = 5;
let y = 2;
JavaScript Addition
Adding
let x = 5;
let y = 2;
let z = x + y;
JavaScript Multiplication
Multiplying
let x = 5;
let y = 2;
let z = x * y;
Arithmetic Operators
Assignment Operators
Comparison Operators
String Operators
Logical Operators
Bitwise Operators
Ternary Operators
Type Operators
let a = 3;
Operator Description
+ Addition
- Subtraction
* Multiplication
** Exponentiation (ES2016)
/ Division
++ Increment
-- Decrement
Note
ADVERTISEMENT
JavaScript Assignment Operators
Assignment
let x = 10;
x += 5;
= x=y x=y
+= x += y x = x + y
-= x -= y x = x - y
*= x *= y x = x * y
/= x /= y x = x / y
%= x %= yx = x % y
**= x **= y x = x ** y
Note
Operator Description
== equal to
? ternary operator
Note
Example
Example
Example
Example
Note
Adding two numbers, will return the sum, but adding a number and a string
will return a string: