Previous Next

JavaScript Number

Numbers are a fundamental data type in JavaScript that represents numerical values. They can be either integer or floating-point numbers.

Example:

let x = 4;
let y = 4.13;

JavaScript Number Methods

There are various methods available in JavaScript Date object.

Method Description
isNaN() It determines whether the provided value is NaN.
isInteger() It determines whether the provided value is an integer.
parseFloat() It parses a string argument and returns a floating-point number.
parseInt() It parses a string argument and returns an integer number.
toFixed() Formats a number using fixed-point notation.
toString() It converts a number to a string.

Example:

let x = 10;
console.log(Number.isInteger(a));

let y = NaN;
console.log(Number.isNaN(b));

let c = parseInt('05');
console.log(c);

Output:

true
true
6
Previous Next