Javascript operators are the symbols that we use to perform operations on data. They act as the verbs of programming.
Press enter or click to view image in full size
The most common operators you’ll use every day are:
Arithmetic operators:
Addition(+): Add the values or concatenate strings.
Subtraction(-): Subtract the values.
Multiplication(*): Multiplies the values.
Division(/): Divides the value.
Remainder(%): Gives the remainder from division.
Exponentiation(**): Raises the base to an exponent power.
Increment(++): Adds 1 to the value.
Decrement(- -): Subtracts 1 from the value.
Assignment Operators:
Assignment(=): Assigns a value.
Addition Assignment(+=): Adds and assigns the value.
Subtraction Assignment(-=): Subtracts and assigns the value.
Multiplication Assignment(*=): Multiplies and assigns the value.
Division Assignment(/=): Divides and assigns the value.
Get Hifza Waheed’s stories in your inbox
Join Medium for free to get updates from this writer.
Comparison Operators:
Loose Equality(==): Only values are compared not their types.
Strict Equality(===): Values and their data types both are compared.
Loose Inequality(!=): Checks only if two values are not equal.
Strict Inequality(!==): Checks if both values and data types are not equal.
Greater Than(>): Give true only if the left value is larger.
Less Than(<): Give true only if the left value is smaller.
Greater Than or Equal To(> =): Give true if left is larger or equal.
Less Than or Equal To(< =): Give true if left is smaller or equal
Logical Operators:
Logical AND(&&): Returns true if both expressions are true.
Logical OR(||): Returns true if at least one expression is true.
Logical NOT(!): Inverses the boolean value of an operand.
Advanced & Unary Operators:
typeof: Returns a string that indicates the data type of a value.
Ternary Operator(? :): A short-hand for an if-else statemente. For example;(condition ? if_true: if_false)
Nullish Coalescing(??): Returns the right-hand operand when the left is null or undefined. Otherwise, it returns the left-hand side value.
Optional Chaining(?): Prevents the code from crashing when tried to read a property or call a method on something that turns out to be null or undefined. Instead of throwing a fatal error, it stops the operation and returns undefined.