Loading

Quipoin Menu

Learn • Practice • Grow

java-script / Datatypes in JS
interview

Q1. What Are Datatypes ?
Data types define the type of value a variable can store. JavaScript supports different types of data such as numbers, strings, objects, and more.
Data types help JavaScript understand how to store and process values.


Q2. How Many Types of Data Types Exist in JavaScript?
JavaScript has two main categories of data types:
1. Primitive Data Types
2. Non-Primitive (Reference) Data Types


Q3. What Are Primitive Data Types in JavaScript?
Primitive data types store single values and are immutable.

Types of Primitive Data Types:
  • Number
  • String
  • Boolean
  • Undefined
  • Null
  • BigInt
  • Symbol
Example

let num = 10;            // Number
let name = "John";       // String
let isActive = true;     // Boolean
let data;                // Undefined
let value = null;        // Null


Q4. What Are Non-Primitive Data Types?
Non-primitive data types store collections of values or complex data.

Example
  • Object
  • Array
  • Function
Example
let person = {
    name: "John",
    age: 30
};

let numbers = [10, 20, 30];

These data types store multiple values.


Q5. How Can You Check the Data Type of a Variable?
JavaScript provides the typeof operator to check data types.

Example
let name = "John";
console.log(typeof name);

Output
string