Boolean
A logical data type that represents one of two possible values: true or false.
Operators
Logical operators
- Conjunction:
a and b - Disjunction:
a or b - Negation:
not aornot(a)
Note: Use
and,or, andnot— not&&,||, or!.
Comparison operators
- Equality:
a == b - Inequality:
a != b
Ternary operator
You can use the ternary operator to write compact, inline conditional expressions in the format: condition ? trueValue : falseValue.
product.price > 100 ? 'premium' : 'value'; // if price is greater than 100 "premium" otherwise "value"Null coalescing operator
The ?? operator returns the right-hand value when the left-hand value is null. It can be chained.
customer.nickname ?? 'Guest'; // "Guest" if nickname is null
customer.nickname ?? customer.firstName ?? 'Guest'; // chainableFunctions
bool
Convert the input into a boolean value; an error is thrown if the conversion is not possible.
bool('true'); // true
bool('false'); // falsetype
Returns the type of the given value as a string.
type(42); // "number"
type("hello"); // "string"
type(true); // "bool"
type([1, 2, 3]); // "array"