|
Java-Script Tutorial |
Introduction |
Variables |
Operators |
Statements |
Loops |
Functions |
Objects |
Arrays |
Browser Objects |
Form DOM |
Ask Your Doubts |
Feedback |
|
|
|
| |
|
Operator Precedence Order
|
|
Topic |
What is the precedence of the operators or calculation in an expression?
Which calculation or operation will be executed first division or addition?
|
|
Explanation |
Operators Execution Order:
When the expression or the formula has more operators
they will follow the following order of precedence.
| Precedence Order | Operator (Symbol) | Operator in Words |
| 1 | !, ++, --, ~ | Not, Increment, Decrement |
| 2 | *, /, %, +, - | Multiplication, Division, Modulus, Addition, Subtraction |
| 3 | << , >>, >>> | - |
| 4 | <, <=, >, >= | Less Than, Less than or equal to, Greater Than, Greater than or equal to |
| 5 | ==, !=, ===, !== | Equals Comparison, Not Equals, Strictly Equals, Strictly Not Equals |
| 6 | &, |, ^, &&, || | Bitwise AND, Bitwise OR, Bitwise Exclusive OR, Logical AND, Logical OR |
| 7 | ?: | Ternary Operator |
| 8 | Assignment Operators
=, +=, -=, /=, *=, %=, <<=, >>=, >>>=, &=, ^= | Assign, other assignment operators |
Say we have an expression a = 4*2+4;.
Here as we can note from the table. Operator "*" (multiplication) has top preference
than "=" (equals) and "+" (addition), so 4*2 will be executed first.
Now the expression is a = 8+4;
In this "+" has highest preference so addition will be done. The result is equated to a and so a becomes 12.
|
Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script.
Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.
|
|
|