Converting a Number to a String in JavaScript
In JavaScript, you often need to convert numbers to strings, especially when concatenating values, displaying data in the UI, or storing numeric values as text. The two most common ways to do this are using String() and .toString().
Using String() (Global Function)
The String() function converts any value into a string. It works with numbers, null, undefined, booleans, and objects.
Using .toString(radix) to Convert Number Bases
You can pass a radix (base) as an argument to convert the number into a different numeral system. Use String(value) when working with unknown types (e.g., numbers, booleans, null).
✔ Use .toString() when working with only numbers and need to convert bases.