Equal priority of mathematical operations in JavaScript

Multiplication and division have the same precedence and are computed in turn from left to right. Let's look at an example to understand what is meant. The following code will first perform division and then multiplication:

let a = 8 / 2 * 4; alert(a); // shows 16 (the result of 4 * 4)

If you rearrange operations, then multiplication will be performed first, and then division:

let a = 8 * 2 / 4; alert(a); // shows 4 (the result of 16 / 4)

In the below example, each new division operation will be applied to the previous one:

let a = 16 / 2 / 2 / 2; alert(a); // shows 2

Determine what will be displayed on the screen without running the code:

let a = 8 / 2 * 2; alert(a);

Determine what will be displayed on the screen without running the code:

let a = 8 * 4 / 2 / 2; alert(a);
enru