JavaScript does not distinguish between integer values and floating point values. Number types can be stored. If you pass a string to the Number() conversion function, it attempts to convert it to an integer or floating point number.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
JavaScript does not distinguish between integer values and floating point values. Number types can be stored.
If you pass a string to the Number() conversion function, it attempts to convert it into an integer or floating point number.
JavaScript Numeric
JavaScript has only one numeric type.
You can use or not use decimal points when writing values:
Example:
<!DOCTYPE html> <html> <body> <h2>JavaScript 数值</h2> <p>写数值时用不用小数点均可:</p> <p id="demo"></p> <script> var x1 = 34.00; var x2 = 34; var x3 = 3.14; document.getElementById("demo").innerHTML = x1 + "<br>" + x2 + "<br>" + x3; </script> </body> </html>
Result:
##[Recommended learning :javascript advanced tutorial】
The above is the detailed content of Does javascript distinguish between integers and floating point numbers?. For more information, please follow other related articles on the PHP Chinese website!