if
Execute an action depending on whether a condition is met
Definition
any if(any $condition, any $trueValue, any $falseValue)
Returns $trueValue if $condition is truthy and $falseValue if $condition is falsy.
Parameters
any $condition
The value to evaluate the truthfulness of.
any $trueValue
The value to return in case $condition evaluates to true.
any $falseValue
The value to return in case $condition evaluates to false.
Returns
any
$trueValue or $falseValue, depending on the Boolean value of $condition.
Examples
{
a: if(`true`, '1', '0'),
b: if(`false`, '1', '0'),
c: if('foo', '1', '0'),
d: if(`null`, '1', '0'),
e: if([`0`, `1`], '1', '0')
}{
"a": "1",
"b": "0",
"c": "1",
"d": "0",
"e": "1"
}Updated 6 months ago