The following example illustrates the use of the toString method with a radix argument. The return value of function shown below is a Radix conversion table.
function CreateRadixTable (){
var s = "";
// Create table heading.
s += "Hex Dec Bin \n";
for (x = 0; x < 16; x++)
{
s += " ";
// Convert to hexidecimal.
s += x.toString(16);
s += " ";
if (x < 10) s += " ";
// Convert to decimal.
s += x.toString(10);
s += " ";
// Convert to binary.
s += x.toString(2);
s += "\n";
}
return(s);
}