Implicit conversion (Definition)

Type conversions that happen automatically.

In JavaScript, the type of a value may be promoted or demoted (coerced) from one kind to another according to the context in which it is used.

A number becomes a string if it is used in a string concatenation.

A string becomes a number if it contains a numeric value and if it is used in an arithmetic expression.

This happens automatically as expressions are evaluated.

The specific behavior depends on the data type of the value at the time the expression is invoked. It also depends on the type of expression being invoked.

This also affects the values yielded by expressions when they are used as operands in other expressions. In this case the value is an ephemeral item not stored in a variable nor in a visible container that the script can access; nevertheless, it behaves as any other value would.

The result of a function call may be affected in the same way when it is used in an expression.

Refer to the descriptions of each of the primitive value types for details of the result of a type conversion on a value of that type.

See also:Array(), Boolean literal, Boolean(), Cast operator, Date(), Function(), Number(), Numeric literal, Object(), String literal, String(), ToBoolean, ToInt32, ToInteger, ToNumber, ToObject, ToPrimitive, ToString, ToUint16, ToUint32