
JavaScript Operations
JavaScript operators assign values, compare values, execute arithmetic operations, and so on. It's likely that you are already familiar with many of these like addition +, subtraction -, multiplication *, and division /.
JavaScript Expressions
A JavaScript expression contains both operators and operands. In general, it can be regarded as any valid unit of code that corresponds to a value.
operand - what operators are applied to. For instance in the expression
8 * 3there are two operands. The left operand is the8and the right operand is the3. Operands can also be referred to as arguments.operator - the verb of the expression that denotes what we're doing to the operands. JavaScript has the following types of operators:
assignment operators
comparison operators
arithmetic operators
bitwise operators
logical operators
string operators
conditional (or ternary) operators
comma operator
unary operator
relational operators
- unary expression - consists of a single operand, one before or one after the operator:
operator operand: ++x; or: operand operator x++;
- binary expression - requires two operands:
operand1 operator operand2
js3 + 46 * y
- ternary expression - an only JavaScript operator that creates a ternary expression is a conditional operator with the syntax:
condition? val1 and val2. Assuming condition istrue, the operation has the result of val1, otherwise, it has the result ofval2.
jsage >= 21 ? 'alcoholic' : 'non-alcoholic'
Assignment Operators
Using the assignment operator, one assigns a numerical value to its left operand depending on that of its right operand. For simple assignments, you can use =
jsx = y
For complex assignments, you can use compound assignment operators like the following examples:
jsx += yx -= y
Which is equivalent to:
jsx = x + yx = x - y
Destructuring
In complex assignment problems, you can use destructuring to extract data from arrays or objects using a syntax that matches the structure of array or object data.
jslet foo = ['one', 'two', 'three']// without destructuringlet one = foo[0]let two = foo[1]let three = foo[2]// with destructuringlet [one, two, three] = foo
Comparison Operators
In the comparison operator, operands are examined and a logical result is generated (true or false) based on the result of the comparison.

Look at the more details: MDN
Arithmetic Operators
The arithmetic operators use numerical values (such as words or variables) during their operands and always assign one number.

Look at the more details: MDN
Bitwise Operators
Bitwise operators handle operands in the context of a set of 32 bits (ones and zeros), rather than decimal, octal, or hexadecimal numbers. For instance, decimal 10 has a binary number of 1010. In JavaScript, Bitwise operators are assigned to such binary values, however, they return standard JavaScript numerical values.

Look at the more details: MDN
Logical Operators
There are several logic operators that are commonly used with boolean (logic) values; when they are returning a boolean value. Although the && and || operators always return the value this is the specified operands, therefore when these operators interact with non-Boolean values, they may return a non-Boolean result.

Look at the more details: MDN
String Operators
The + operator (in conjunction with the += compound operator) is also effectively used as a concatenation operator when dealing with strings.
jsconsole.log('alpha' + 'bet') // logs the string 'alphabet' to the console
Other Unary Operators
delete
The delete operator removes an element, an object's attribute, or an element at a specific index in an array
jsdelete objectNamedelete objectName.propertydelete objectName[index]
typeof
The typeof operator returns a string specifying the type of the undetected operand with the syntax typeof operand. an operand is a keyword, string, or variable for which type is to be returned
jslet shape = 'round'let size = 1let foo = ['Apple', 'Mango', 'Orange']typeof shape // returns "string"typeof size // returns "number"typeof foo // returns "object"
void
The void operator instructs an expression it should be evaluated without returning a value with the syntax void evaluate, expression is a JavaScript expression to be evaluated.
js<a href="javascript:void(0)">Click here to do nothing</a>
Relational Operators
in
The in operator indicates the given property in the specified data.
jslet trees = ['redwood', 'bay', 'cedar', 'oak', 'maple']3 in trees // returns true6 in trees // returns false'length' in trees // returns true (length is an Array property)'PI' in Math // returns truelet mycar = { make: 'Honda', model: 'Accord', year: 1998 }'make' in mycar // returns true
instanceof
The instanceof operator returns true when the specified object of the specified object category.
jslet theDay = new Date(2018, 1, 1)theDay instanceof Date // returns true
Operator Precedence
The appearance of operators indicates the order they are executed when computing an expression. You can modify operator ordering by using brackets.
The following table describes the precedence of operators, from highest to lowest:

Look at the more details: MDN
all posts