javascript

Number Literals


 

Number literals are used to represent numerical values


There are common types of number literals in JavaScript:
 

1. Integer Literals

These are whole numbers without any decimal point.

 

Example:

let num = 42;

 

2. Floating-Point Literals

These are numbers with decimal points.

 

Example:

let floatNumber = 3.14;

 

3. Exponential Notation Literals

JavaScript allows representing very large or very small numbers using exponential notation.

 

Example:

let bigNumber = 6.022e23; 
let smallNumber = 1.6e-19;

 

4. Binary Literals

Represented with 0b or 0B prefix, followed by binary digits (0 or 1).

 

Example:

let binaryNumber = 0b1010;