Numbers in JavaScript: Handling and Operations

Rumman Ansari   Software Engineer   2024-07-09 09:48:23   5566  Share
Subject Syllabus DetailsSubject Details
☰ TContent
☰Fullscreen

JavaScript has only one type of numbers.

Numbers can be written with, or without decimals:

<span class="pln">
</span><span class="kwd">var</span><span class="pln"> a </span><span class="pun">=</span><span class="pln"> </span><span class="lit">14.00</span><span class="pun">;</span><span class="pln">     </span><span class="com">// Written with decimals</span><span class="pln">
</span><span class="kwd">var</span><span class="pln"> b </span><span class="pun">=</span><span class="pln"> </span><span class="lit">14</span><span class="pun">;</span><span class="pln">        </span><span class="com">// Written without decimals</span><span class="pln">
</span>

 

Extra large or extra small numbers can be written with scientific (exponential) notation:

<span class="pln">
</span><span class="kwd">var</span><span class="pln"> y </span><span class="pun">=</span><span class="pln"> </span><span class="lit">163e6</span><span class="pun">;</span><span class="pln">      
</span><span class="kwd">var</span><span class="pln"> z </span><span class="pun">=</span><span class="pln"> </span><span class="lit">163e-6</span><span class="pun">;</span><span class="pln">      
</span>

You will learn more about numbers later in this tutorial.


No Questions Data Available.
No Program Data.

Stay Ahead of the Curve! Check out these trending topics and sharpen your skills.