# Expressions¶

Expressions allow for defining predicates or computing new variables based on existing data. The expression language is based on JavaScript, but provides only a limited set of features, guaranteeing secure execution.

Expressions can be used with the filter and formula transforms.

## Usage¶

All basic arithmetic operators are supported:

(1 + 2) * 3 / 4

The current data row is provided as the `datum`

object. Its properties (columns)
can be accessed by using the dot or bracket notation:

datum.foo + 2

If the name of the property contains special characters such as "`.`

", "`!`

",
or "` `

" (a space) the bracket notation must be used:

datum['A very *special* name!'] > 100

## Conditional operators¶

Ternary operator:

datum.foo < 5 ? 'small' : 'large'

And an equivalent `if`

construct:

if(datum.foo < 5, 'small', 'large')

## Provided constants and functions¶

Common mathematical functions are supported:

(datum.u % 1e-8 > 5e-9 ? 1 : -1) * (sqrt(-log(max(1e-9, datum.u))) - 0.618) * 1.618

The full list of built-in constants and functions are documented in vega-expression.