Cast operator (Definition)

A way of converting data types.

Primitive values can be converted from one to another or rendered as objects by using object constructors to convert the values.

Type Name:Description:
AggregateA collection of atomic types assembled collectively into an object.
ArithmeticAll types that yield a value that can be operated on numerically.
ArrayCollections of objects and identifiers assembled into a sequence.
BasicThe fundamental simple, non object types.
BooleanThis type can store and yield true or false values.
CompletionUsed only as the intermediate result of expression evaluations and cannot be stored in object properties.
ListUsed only as the intermediate result of expression evaluations and cannot be stored in object properties.
NullThis has exactly one value, null, and is distinct from undefined.
NumberInteger and floating-point values are all stored in a generic number type.
ObjectAn object is an unordered collection of properties. Each property consists of a name, a value, and a set of attributes.
ReferenceUsed only as the intermediate result of expression evaluations and cannot be stored in object properties.
ScalarThe non-object types.
StringStrings are arrays of characters that are accessible individually by indexing their position in the sequence.
UndefinedThis value is returned by variables that have not yet been assigned a value.

In compiled languages, this is called casting. In JavaScript the values are actually converted using methods and function calls on the objects. This yields a new value rather than making the old one look like the new type that is required. It is really conversion rather than casting.

See also:Aggregate type, Array simulation, Escape sequence (\), escape(), MakeDate(), MakeDay(), MakeTime(), Native object, null, null, Operator Precedence, Primitive value, unescape()