Skip to content

otherwise

Returns a fallback value if primary is null.

otherwise(primary:any, fallback:any) -> any

The otherwise function evaluates its arguments and replaces primary with fallback where primary would be null.

The expression to return if not null.

The expression to return if primary evaluates to null.

from {x: 1}, {x: 2}, {}
x = x.otherwise(-1)
{x: 1}
{x: 2}
{x: -1}

Last updated: