Assignment
Value assignment has the following syntax:
(const|var) identifier[: type] = value
.
const
indicates thatidentifier
is a constant that stores an immutable value.var
indicates thatidentifier
is a variable that stores a mutable value.: type
is a type annotation foridentifier
, and may be omitted if the data type ofvalue
can be inferred.
Constants and variables must have a value. If no known value can be given, the
undefined
value, which
coerces to any type, may be used as long as a type annotation is provided.
Where possible, const
values are preferred over var
values.