Utilizor
Contact Us

Type Conversion

Converting between data types.

Type Conversion

JavaScript variables can be converted to a new variable and another data type:

  • By the use of a JavaScript function
  • Automatically by JavaScript itself

Converting Strings to Numbers

Number() converts a variable (or a value) to a number.

Converting Numbers to Strings

String() converts a variable (or a value) to a string.

Example

let x = "10";
let y = Number(x); // 10