How to convert int to a string in Node.js
Learn, how to convert a given int to a string in Node.js with the help of examples.
Using Number.toString() method
To convert a int to a string, we can use the Number.toString() method in Node.js.
Here is an example:
const num = 10;
const str = num.toString();
console.log(str);
Output:
"10"
Similarly, we can also convert the int to a string by adding an empty string (''
) in front of a int.
Here is an example
const num = 20;
const string = '' +num;
console.log(string); // "20"
Additional resources
You can also checkout similar tutorials by reading the following: