Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

4.6.3. Order of Operations¶

/*Due to an historical quirk, an exception to the left-to-right rule 
is the exponentiation operator **. A useful hint is to always use 
parentheses to force exactly the order you want when exponentiation 
is involved:*/

// the right-most ** operator is applied first
console.log(2 ** 3 ** 2)

// use parentheses to force the order you want
console.log((2 ** 3) ** 2)

//512
//64
Source by education.launchcode.org #
 
PREVIOUS NEXT
Tagged: #Order
ADD COMMENT
Topic
Name
6+7 =