Skip to content

Operators

Reference

Parts of the documentation in this page are taken directly from Mozjexl`s Readme.md

Unary Operators

Operation Symbol
Negate !
  • Negate will work on Number, String and Boolean.
    • !true -> false, and !false -> true
    • !1 -> false, and !0 -> false
    • !'' -> true and !'Hello' -> false
    Negate on objects and arrays

    You can also apply negate on objects on arrays, !{} gives false and ![] also gives false implying even empty objects and arrays are considered true internally and when negated give false.

Binary Operators

Operation Symbol
Add, Concat +
Subtract -
Multiply *
Divide /
Divide and floor //
Modulus %
Power of ^
Logical AND &&
Logical OR ||

Logical Operators

Comparison Symbol
Equal ==
Equals ignore case _=
Not equal !=
Greater than >
Greater than or equal >=
Less than <
Less than or equal <=
Element in array or string in
in operator on array of objects

The in operator can be used to check for a substring: 'Cad' in 'Ron Cadillac', and it can be used to check for an array element: 'coarse' in ['fine', 'medium', 'coarse']. However, the == operator is used behind-the-scenes to search arrays, so it should not be used with arrays of objects. The following expression returns false: {a: 'b'} in [{a: 'b'}].

Ternary Operator

  • You can simply use <conditional> ? trueValue : falseValue anywhere in the transforms.