All of these will work:
`${num}`
num.toString()
'' + num
String(num)
Answer from Zihan Chen on Stack OverflowW3Schools
w3schools.com › jsref › jsref_string.asp
JavaScript String() Method
It is supported in all browsers: Convert different values to strings: String(Boolean(0)); String(Boolean(1)); String([1,2,3,4]); Try it Yourself » · ❮ Previous JavaScript Global Methods Next ❯ · ★ +1 · Sign in to track progress ·
Top answer 1 of 4
2
All of these will work:
`${num}`
num.toString()
'' + num
String(num)
2 of 4
0
Seems that var str = '' + num is the fastest way to convert a number to a string (num being the number variable).
let num = 5
var str = '' + num
(results based on this benchmark: http://jsben.ch/#/ghQYR)
Videos
07:40
How to Convert Strings to Numbers & Numbers to Strings in JavaScript ...
01:30
JavaScript Basics - How to Convert a Number to a String - YouTube
07:35
String Casting JavaScript - [Convert a Value to String in JavaScript] ...
03:09
DevTips Daily: Convert a number to a string in JavaScript - YouTube
05:30
Convert to string | String data type in JavaScript | Part 20 | ...
01:45
JavaScript Basics - How To Convert An Array Into A String - YouTube
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › toString
String.prototype.toString() - JavaScript | MDN
January 25, 2026 - The String object overrides the toString method of Object; it does not inherit Object.prototype.toString(). For String values, the toString method returns the string itself (if it's a primitive) or the string that the String object wraps.
Medium
medium.com › dailyjs › 5-ways-to-convert-a-value-to-string-in-javascript-6b334b2fc778
5 Ways to Convert a Value to String in JavaScript | by Samantha Ming | DailyJS | Medium
May 27, 2019 - JavaScript news and opinion. ... It’s also the one I use because it’s the most explicit — making it easy for other people to follow the intention of your code 🤓 · Remember the best code is not necessarily the most clever way, it’s the one that best communicates the understanding of your code to others 💯 · const value = 12345;// Concat Empty String value + '';// Template Strings `${value}`;// JSON.stringify JSON.stringify(value);// toString() value.toString();// String() String(value);// RESULT // '12345'
GeeksforGeeks
geeksforgeeks.org › javascript › convert-a-number-to-a-string-in-javascript
Convert a Number to a String in JavaScript - GeeksforGeeks
July 23, 2025 - These are the following ways to Convert a number to a string in JavaScript: This method belongs to the Number.Prototype object. It takes an integer or a floating-point number and converts it into a string type. JavaScript · let a = 20; console.log(a.toString()); console.log((50).toString()); console.log((7).toString(2)); // (7 in base 2, or binary) Output ·
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-convert-an-object-to-string-using-javascript
How to convert an object to string using JavaScript ? - GeeksforGeeks
July 11, 2025 - It first creates a boolean value ... strings using the String() constructor. Similarly, it converts a number to a string. Finally, it logs the types before and after conversion for each case. JSON.stringify() converts the JavaScript object to a string which is needed ...
2ality
2ality.com › 2012 › 03 › converting-to-string.html
Converting a value to string in JavaScript
Both approaches use the internal ToString() operation to convert primitives to string. “Internal” means: a function specified by the ECMAScript 5.1 (§9.8) that isn’t accessible to the language itself.
Bbody
jsstringconverter.bbody.io
Multiline JavaScript Converter
Converts multiline text into a JavaScript multiline string. This includes both concatenated string in ECMA5 and the new template literal in ECMA6
W3Schools
w3schools.com › jsref › jsref_tostring_number.asp
JavaScript Number toString() Method
The toString() method is used by JavaScript when an object needs to be displayed as a text (like in HTML), or when an object needs to be used as a string.
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String
String - JavaScript | MDN
Many built-in operations that expect strings first coerce their arguments to strings (which is largely why String objects behave similarly to string primitives). The operation can be summarized as follows: Strings are returned as-is. ... Numbers are converted with the same algorithm as toString(10).
Top answer 1 of 9
293
They do behave differently when the value is null.
null.toString()throws an error - Cannot call method 'toString' of nullString(null)returns - "null"null + ""also returns - "null"
Very similar behaviour happens if value is undefined (see jbabey's answer).
Other than that, there is a negligible performance difference, which, unless you're using them in huge loops, isn't worth worrying about.
2 of 9
39
There are differences, but they are probably not relevant to your question. For example, the toString prototype does not exist on undefined variables, but you can cast undefined to a string using the other two methods:
var foo;
var myString1 = String(foo); // "undefined" as a string
var myString2 = foo + ''; // "undefined" as a string
var myString3 = foo.toString(); // throws an exception
http://jsfiddle.net/f8YwA/
W3Schools
w3schools.com › js › js_type_conversion.asp
JavaScript Type Conversions
The global method String() can convert numbers to strings.
DigitalOcean
digitalocean.com › community › tutorials › how-to-convert-data-types-in-javascript
How To Convert Data Types in JavaScript | DigitalOcean
August 24, 2021 - Because of this, JavaScript will attempt to convert unexpected values rather than reject them outright. This implicit conversion is known as type coercion. Some methods will automatically convert values in order to make use of them. The alert() method takes a string as its parameter, but it will automatically convert other types into strings.