из числа в строку





js/script.js
  • var str0 = String(300);
  • var val0 = 255;
  • var str1 = val0.toString();
  • var val1 = 255;
  • var val2 = 123.456789;
  •  
  • function funMake() {
  •  document.write(str0 + '<br />');
  •  document.write(str1 + '<br />');
  •  document.write(val1.toString(2) + '<br />');
  •  document.write('0' + val1.toString(8) + '<br />');
  •  document.write('0x' + val1.toString(16) + '<br />');
  •  document.write(val2.toFixed(2) + '<br />');
  • }
 var str0 = String(300);
var val0 = 255;
var str1 = val0.toString();
var val1 = 255;
var val2 = 123.456789;

function funMake() {
 document.write(str0 + '
'); document.write(str1 + '
'); document.write(val1.toString(2) + '
'); document.write('0' + val1.toString(8) + '
'); document.write('0x' + val1.toString(16) + '
'); document.write(val2.toFixed(2) + '
'); }


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  • <script>
  •  funMake();
  • </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  • <script>
  •  funMake();
  • </script>
  • </body>
  • </html>