Function: check()
check(
value,ifTrue,ifFalse):any
Defined in: functions/check.ts:18
Checks whether the given value is true or false. If the value is true, returns the first parameter, otherwise returns the second parameter.
Note: You don't have to give a boolean to value. For example "text" is returns true and "" is returns false, or 1 is returns true and 0 is returns false.
Parameters
value
any
The value to check.
ifTrue
any
The value to return if the value is true.
ifFalse
any
The value to return if the value is false.
Returns
any
The value.
Deprecated
Use the ternary operator (value ? ifTrue : ifFalse) instead.
Example
check(true, "Hello", "World"); // "Hello"
check(false, "Hello", "World"); // "World"
check("text", "Hello", "World"); // "Hello"
check("", "Hello", "World"); // "World"