Loading

Quipoin Menu

Learn • Practice • Grow

java-script / Number in Javascript
interview

Q1. What is the Number Data Type in JavaScript?
The Number data type is used to store numeric values, including integers and decimal numbers.

JavaScript uses a single Number type for all numeric values.

Example
let age = 25;
let price = 99.99;

Both integer and floating-point values are stored using the Number data type.


Q2. Does JavaScript Have Separate Types for Integer and Float?
No, JavaScript does not have separate types for integers and floating-point numbers. Both are stored under the Number data type.

Example
let a = 10;     // Integer
let b = 10.5;   // Floating point

JavaScript treats both values as Numbers.


Q3. What is NaN in JavaScript?
NaN stands for Not-a-Number. It represents an invalid numeric operation.

Example
let result = "Hello" / 2;
console.log(result);

Output
NaN

JavaScript cannot divide text by a number, so it returns NaN.


Q4. How Can You Check if a Value is NaN?
JavaScript provides the isNaN() function to check whether a value is not a number.

Example
console.log(isNaN("Hello"));

Output
true


Q5. What is Infinity in JavaScript?
Infinity is a special numeric value that represents a number greater than any other number.

Example
let value = 10 / 0;
console.log(value);

Output
Infinity