e01.org

Type conversion

Type conversion (or typecasting) means transfer of data from one data type to another. Implicit conversion happens when the compiler (for compiled languages) or runtime (for script languages like JavaScript) automatically converts data types. The source code can also explicitly require a conversion to take place.

Type conversion (or typecasting) means transfer of data from one data type to another. _Implicit conversion_ happens when the compiler (for compiled languages) or runtime (for script languages like JavaScript) automatically converts data types. The source code can also _explicitly_ require a conversion to take place.

For example, given the expression `"foo" + 1`, the Number `1` is implicitly converted into a String and the expression returns `"foo1"`. Given the instruction `Number("0x11")`, the string `"0x11"` is explicitly converted to the number `17`.

## See also

- [Type conversion](https://en.wikipedia.org/wiki/Type_conversion) (Wikipedia)
- Related glossary terms:
- Type
- Type coercion

source: MDN Web Docs mirror · page

Cite this

"Type conversion". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Glossary/Type_Conversion

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·