JavaScript for Beginners

JavaScript Numbers

All JavaScript numbers are stored as decimal numbers (floating point).

Numbers can be written with, or without decimals:

 

Example :

 

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Numbers</h2>

<p>Numbers can be written with, or without decimals:</p>

<p id=”demo”></p>

<script>
let x1 = 34.00;
let x2 = 34;
let x3 = 3.14;

document.getElementById(“demo”).innerHTML =
x1 + “<br>” + x2 + “<br>” + x3;
</script>

</body>
</html>

 

Output

JavaScript Numbers

Numbers can be written with, or without decimals:

34
34
3.14

 

 

Description :

In JavaScript, numbers are a single data type used to represent both integers (like 100, -5) and floating-point (decimal) numbers (like 3.14, 0.5). Unlike many other programming languages, JavaScript does not have separate types for integers and decimals—all numbers are treated as floating-point (64-bit IEEE 754 format) under the hood.