W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>JavaScript 数字</h1> <p>toString() 方法以基数 2 到 36 输出字符串:</p> <p id="demo"></p> <script> var myNumber = 32; document.getElementById("demo").innerHTML = "32 = " + "<br>" + " Decimal " + myNumber.toString(10) + "<br>" + " Hexadecimal " + myNumber.toString(16) + "<br>" + " Octal " + myNumber.toString(8) + "<br>" + " Binary " + myNumber.toString(2); </script> </body> </html>