Math operations precedence in JavaScript
JavaScript math operations have the same precedence as normal math operations. That is, multiplication and division are done first, addition and subtraction then.
In the following example, 2 is first
multiplied by 2, and then 3
is added to the result:
javascriptlet a = 2 * 2 + 3;
alert(a); // shows 7 (the result of 4 + 3)
Задание 1
Determine what will be displayed on the screen without running the code:
javascriptlet a = 5 + 5 * 3;
alert(a);
Задание 2
Determine what will be displayed on the screen without running the code:
javascriptlet a = 5 + 5 * 3 + 3;
alert(a);
Задание 3
Determine what will be displayed on the screen without running the code:
javascriptlet a = 8 / 2 + 2;
alert(a);
Задание 4
Determine what will be displayed on the screen without running the code:
javascriptlet a = 8 + 2 / 2;
alert(a);