JavaScript Number toString() Method
More "Try it Yourself" examples below.
Definition and Usage
The toString() method converts a number to a string.
Browser Support
Method | |||||
---|---|---|---|---|---|
toString() | Yes | Yes | Yes | Yes | Yes |
Syntax
number.toString(radix)
Parameter Values
Parameter | Description |
---|---|
radix | Optional. Which base to use for representing a numeric value. Must be an integer between 2 and 36.
|
Technical Details
Return Value: | A String, representing a number |
---|---|
JavaScript Version: | ECMAScript 1 |
More Examples
Example
Convert a number to a string, using different bases:
var num = 15;
var a = num.toString();
var b = num.toString(2);
var c = num.toString(8);
var d = num.toString(16);
Try it Yourself »