In Javascript , operator precedence is followed when we perform operators to evaluate mathematical calculation. Higher precedence perform before than the lower precedence i.e multiplication should be done before addition.
Simple Example ->
var b = 8*5 + 3 -1
document.write(b) ; // output will be **42**
because multiplication() operator is high precedence than + and -
Operator Table -> Below table tell you the full description of oder precedence
Operator Description
1) [ ], ( ) -: Array access, Method/function call, grouping .
2) ++ -- - ~ ! delete new typeof void . -: Unary operator,return data type,object creation ,undefined values .
3) / %++ -: Multiplication,division,modulo division .
4)+ - + -: Addition,subtraction,string concatenation .
5) << >> >>> -: Bit shifting .
6) < <= > >= instanceof -: Less than ,less than or equal,greater than,greater than or equal,instanceof .
7) == != === !== -: Equality , inequality, strict equality , and strict inequality .
8) & -: Bitwise And .
9) ^ -: Bitwise XOR .
10) | -: Bitwise OR .
11) && -: Logical And .
12) || -: Logical OR .
13) ?: -: Conditional .
14) = OP= -:Assignment,assignment with operation (like as += and &=) .
Example ->
var math = 10 / 5 * 5 ;<br>
document.write(math); // output is **10**
0 Comment(s)