Skip to main content

Operator Precedence

You can combine the arithmetic operators to form complex mathematical expressions. You may be surprised to learn that ObjectScript's rules for operator precedence are different than those in other languages: there aren't any! Evaluation of an expression proceeds from left to right, without regard for operators.

But this difference really isn't important, because like other languages, you can use parentheses to specify which operations to perform in what order. Complex expressions should always be clarified by using parentheses, no matter which language you're using. Always use parentheses!

SAMPLES>set x = 3 + 5 * 6 - 4

SAMPLES>write x
SAMPLES>set x = 3 + ( 5 * 6 ) - 4

SAMPLES>write x
FeedbackOpens in a new tab