JavaScript toString() Method
Complete Number Object Reference
Definition and Usage
The toString() method converts a Number object to a string and returns the result.
Syntax
NumberObject.toString(radix)
|
Parameter |
Description |
radix |
Optional. Specifies the base radix you would like the
number displayed as. Examples:
- 2 - The number will show as a binary value
- 8 - The number will show as an octal value
- 16 - The number will show as an hexadecimal value
|
Example
In this example we will convert a number to a string:
<script type="text/javascript">
var number = new Number(1337);
document.write (number.toString());
</script>
|
The output of the code above will be:
Try-It-Yourself Demos
toString()
How to use toString() to convert a number to a string.
Complete Number Object Reference
 |

|
|
See why there are 20,000+ Ektron integrations worldwide.
Request an INSTANT DEMO or download a FREE TRIAL today. |
|
|
|