JavaScript operator Priority logic confuses me

The operator priority table I can find is:

https://developer.mozilla.org/en/JavaScript/Reference/Operators/Operator_Precedence

according to the table, both “→” and “*” are associated from left to right, and “→” have a higher priority, so I think a → b * c should be explained as (a → b) * c however, my test in Firefox (using Firebug), tell me:

0x11 >> 1 .... 8 0x11 >> 1 * 2 .... 4 

What bothers me should it be 16?

Well, I understand that we should always use parentheses if the priority is not clear, but should there be a rule or an explanation of what happens?

+4
source share
4 answers

If I look at this table, the * operator has higher priority than >> , so * bound earlier. It is interpreted as:

  • 0x11 >> 1 * 2
  • 0x11 >> (1 * 2)
  • 0x11 >> (2)
  • 0x11 >> 2
+2
source

According to the table with which you are associated * has a higher priority (5) than >> (7); higher priority is listed first in this table, although in a confusing manner, lower numbers are used to indicate higher priority.

+2
source

According to the table you are linking, multiplication has a higher priority (5) than a bit shift (7).

At the top of the table:

The following table is ordered from highest (1) to lowest (17) priority.

+1
source

No, he says * has a higher priority than >> . :)

+1
source

All Articles