Reputation: 71
I run some code and I get same results with or without parenthesis, even if I know that multiplication have higher precedence then division. Here is example:
let calculate = 16 / 30 * 100
I gott same result as
let calculate = (16 / 30) * 100
So I don't know which of them has higher precedence.
Upvotes: 5
Views: 1681
Reputation: 64
See this fiddle: https://www.w3schools.com/code/tryit.asp?filename=FRB0CCQOKZT2
the code is evaluated in this order:
If you have Multiple and Divide in the same equation then it evaluates the first one it encounters. you can override this by using parentheses.
Upvotes: 3
Reputation: 1074295
So I don't know which of them has higher precedence.
Neither, they have the same precedence and associativity; see MDN's page for details.
Almost all programming languages adhere to PEMDAS:
...aka BODMAS:
Upvotes: 8