Interactive online courses HTML Academy
2026-03-09 10:55 Diff

What should you do if there are two values ​​of different types, and you do not want to rely on the default cast? Use can cast “by hand”.

For example, you can cast a numeric value to a string type. One way is to use the number.toString() command. For example:

var number = 1; // Logs number: 1 (number) console.log(number); // Logs string: "1" (string) console.log(number.toString());