toString() converts a number to a string of a specified radix.
Syntax of the toString()
Method
toString()
accepts only one optional argument. Here is the syntax:
The radix
argument specifies the base into which you wish to convert the number.
Examples of the toString()
Method
Below are examples of the toString()
method.
Convert 45
to a decimal string
Try Editing It
Note that the snippet above is equivalent to:
Try Editing It
CodeSweetly adsUse CSS Grid like a pro
Learn CSS Grid with live examples and images.
Check it out
Convert 45
to a binary string
Try Editing It
Convert negative 45
to a binary string
Try Editing It
Convert 45
to an octal string
Try Editing It
Convert 45
to a hexadecimal string
Try Editing It
Convert 45
to a vigesimal string
Try Editing It