like this:

var foo = 45;
var bar = '' + foo;

Actually, even though I typically do it like this for simple convenience, over 1,000s of iterations it appears for raw speed there is an advantage for .toString()

See Performance tests here (not by me, but found when I went to write my own): http://jsben.ch/#/ghQYR

Fastest based on the JSPerf test above: str = num.toString();

It should be noted that the difference in speed is not overly significant when you consider that it can do the conversion any way 1 Million times in 0.1 seconds.

Update: The speed seems to differ greatly by browser. In Chrome num + '' seems to be fastest based on this test http://jsben.ch/#/ghQYR

Update 2: Again based on my test above it should be noted that Firefox 20.0.1 executes the .toString() about 100 times slower than the '' + num sample.

Answer from scunliffe on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › jsref_tostring_number.asp
JavaScript Number toString() Method
Convert a number to a string: let ... » · The toString() returns a number as a string. Every JavaScript object has a toString() method....
🌐
Online String Tools
onlinestringtools.com › convert-decimal-to-string
Convert Decimal to a String – Online String Tools
Simple, free and easy to use online tool that converts decimal to a string. No intrusive ads, popups or nonsense, just a decimal to string converter. Load a decimal, get a string.
🌐
W3Schools
w3schools.com › js › js_type_conversion.asp
W3Schools.com
The global method String() can convert numbers to strings.
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Number › toString
JavaScript Number toString() - Convert to String | Vultr Docs
September 27, 2024 - Enable JavaScript numbers to be ... in JavaScript applications. Define a decimal number. Apply the toString() method to convert it to a string....
🌐
MathWorks
mathworks.com › matlab › language fundamentals › data types › data type conversion
Convert Numeric Values to Text - MATLAB & Simulink
The simplest way to combine text and numbers is to use the plus operator (+). This operator automatically converts numeric values to strings when the other operands are strings.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › c++ › converting-number-to-string-in-cpp
Converting Number to String in C++ - GeeksforGeeks
July 23, 2025 - The to_string() function can be used to convert an integer, floating point values, or any number to a string.
🌐
PhraseFix
phrasefix.com › tools › decimal-to-string
Decimal to String Converter - PhraseFix
Free online tool that converts decimal numbers to string. Simply enter the decimal and the online tool will convert it into text.
🌐
CoreUI
coreui.io › answers › how-to-convert-a-number-to-a-string-in-javascript
How to convert a number to a string in JavaScript · CoreUI
September 27, 2025 - const number = 42 const stringValue = number.toString() // Result: '42' const floatNumber = 3.14159 const roundedString = floatNumber.toString() // Result: '3.14159' The toString() method converts the number to its string equivalent, preserving ...
🌐
freeCodeCamp
freecodecamp.org › news › javascript-number-to-string-how-to-use-tostring-to-convert-an-int-into-a-string
JavaScript Number to String – How to Use toString to Convert an Int into a String
March 22, 2021 - The toString() method is a built-in method of the JavaScript Number object that allows you to convert any number type value into its string type representation. How to Use the toString Method in JavaScript To use the toString() method, you simply ...
🌐
ProjectPro
projectpro.io › recipes › convert-integer-string-r
How to convert integer number to string in R- Projectpro
January 5, 2024 - A comprehensive guide on how to convert an integer number to string in R.
🌐
Unqork
docs.unqork.io › docs › convert-value-operator-convert-number-to-a-string
How to: Convert a Number to a String
In the Property ID and Label Text fields, enter stringOutput. Click Save Component. Now, it's time to set up your Data Workflow. First, you'll input your Number component into a Convert Value operator. Then you'll cast any number entered in the Number component field to a string.
🌐
Medium
medium.com › @rwijayabandu › how-to-convert-number-to-string-in-javascript-7c08e221e5b0
How to convert number to string in JavaScript? | by Ravithamara | Medium
August 18, 2024 - This method provides a way to represent numeric values as strings, which can be particularly useful when formatting numbers for display or manipulation as text. ... method can be used to convert a number from the decimal number system (base 10) to a string representing the number in other number systems.
🌐
Reddit
reddit.com › r/javahelp › converting a number to a string
r/javahelp on Reddit: Converting a Number to a String
August 14, 2022 -

Hey, all. I was working on some Codewars fundamentals and I came across this problem. My solution was accepted and, on the list of acceptable solutions, I see what seems to be an equally useful solution. I just wondered if there's any reason to use one over the other in any particular situation or if they do the same thing all the time. The passed in variable was some integer num.

My solution was:

return Integer.toString(num);

The other solution I saw was:

return String.valueOf(num);

Any insight would be much appreciated. Thanks!

🌐
freeCodeCamp
freecodecamp.org › news › how-to-convert-integer-to-string-in-java
Int to String in Java – How to Convert an Integer into a String
January 5, 2023 - You can convert variables from one data type to another in Java using different methods. In this article, you'll learn how to convert integers to strings in Java in the following ways: Using the Integer.toString() method. Using the String.valueOf(...