2.6 Glossary: terms related to type conversion
Now that we have taken a closer look at how JavaScript’s type coercion works, let’s conclude with a brief glossary of terms related to type conversion:
In type conversion, we want the output value to have a given type. If the input value already has that type, it is simply returned unchanged. Otherwise, it is converted to a value that has the desired type.
Explicit type conversion means that the programmer uses an operation (a function, an operator, etc.) to trigger a type conversion. Explicit conversions can be:
- Checked: If a value can’t be converted, an exception is thrown.
- Unchecked: If a value can’t be converted, an error value is returned.
What type casting is, depends on the programming language. For example, in Java, it is explicit checked type conversion.
Type coercion is implicit type conversion: An operation automatically converts its arguments to the types it needs. Can be checked or unchecked or something in-between.
[Source: Wikipedia]