⊗jsPmBsMOP 19 of 504 menu

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:

let a = 2 * 2 + 3; alert(a); // shows 7 (the result of 4 + 3)

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

let a = 5 + 5 * 3; alert(a);

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

let a = 5 + 5 * 3 + 3; alert(a);

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 + 2 / 2; alert(a);
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline