Open In App

SASS | Operators

SASS provides and supports a variety of useful operators in order to work with different values. These operators consist of the standard mathematical operators like +, -, /, and *, and apart from them operators of various other types listed below:

Order Of Operations:



SASS follows the most standard order of operators that is from tightest to loosest.

  1. The unary operators: NOT, +, – and /.
  2. The /, * and % operators.
  3. The + and – operators.
  4. The <, <=, > and >= operators.
  5. The == and != operators.
  6. The AND operator.
  7. The OR operator.
  8. The = operator when it is available.

EXAMPLE:



SASS CODE:




@debug 2 + 4 * 6 == 2 + (4 * 6)

Output:

true




@debug true or false and false == true or (false and false)

Output:

true

Parentheses:

Apart from the common order of the operators, their order can be explicitly changed using parentheses. An operation written inside the parentheses is always executed before the operators written outside of it. Parentheses can also be nested. In the case of nested parentheses, the innermost parentheses are executed first.

Example:




@debug (2 + 3) * 4

Output:

20




@debug ((2 + 3) - 1) * 5

Output:

20

Article Tags :