Way2tutorial Snippet Editor
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JS Number Data Types</title> </head> <body> <pre> <!-- Use pre element for work document.writeln() method --> <script type="text/javascript"> var num1 = 5; // Numeric integer value var num2 = 10.5; // Numeric float value var num3 = -30.47; // Negative numeric float value var num4 = 5E4; // 5 x 10 Powers of 4 = 50000 var num5 = 5E-4 // 5 x 10 Powers of -4 = -50000 var num6 = 10 / 0; // Number divide by zero, result is: Infinity var num7 = 10 / -0; // Number divide by negative zero, result is: -Infinity var num8 = 10, num9 = 12.5; // Multiple variable declare and initialize document.writeln('num1: ' + num1); document.writeln('num2: ' + num2); document.writeln('num3: ' + num3); document.writeln('num4: ' + num4); document.writeln('num5: ' + num5); document.writeln('num6: ' + num6); document.writeln('num7: ' + num7); document.writeln('num8: ' + num8); document.writeln('num9: ' + num9); </script> </pre> </body> </html>