JavaScript Numbers


Javascript numbers are primitive data types. It is used to represent the following numeric values such as:

  1. Integer - 12, 55, 18, 1000, 55, etc
  2. Float -11.0, 22.5, 84.4503, 45.50, etc
  3. Exponential - 2.23e5, 4.23e-6, etc
  4. Binary -0b1110, 0b1011, etc
  5. Octal -0o7, 0o67, 0o667, etc
  6. Hexadecimal 0xFF, 0xFFF, 0xFFFF, etc

How To Define Number In Javascript

Followings are the way of defining numbers in javascript:

  • Number literals - Like 10, 25, 45, etc
  • Number Constructor-
  • It is used to convert any string to a number.It is not converted then it converts into NaN.

Creating Javascript Number Using Constructor

Javascript numbers can be created using the Number() constructor function. You have to pass the number as an argument.

Source Code

            const num1 = Number(150);
const num2 = Number(1212.55);          
Try it now

Web Tutorials

Javascript Numbers
Html Tutorial HTML
Javascript Tutorial JAVASCRIPT
Css Tutorial CSS
Bootstrap 5 Tutorial BOOTSTRAP 5
Bootstrap 4 Tutorial BOOTSTRAP 4