Member-only story
JavaScript Interview Questions for Freshers

Source:- JavaScript Developer Interview Questions for Freshers
For more questions and answers visit our website at Frontend Interview Questions
In JavaScript, data types can be categorized into two main groups: primitive and non-primitive (also known as reference types) data types. Here’s an explanation of each:
- Primitive Data Types:
These are immutable data types that store a single value.
a. Boolean: Represents a logical value, either true or false. It is commonly used for conditions and branching in JavaScript.
let isTrue = true;
let a=5;
let isFalse = false;
console.log(isTrue); // Output: true
console.log(isFalse); // Output: false
b. Number: Represents numeric values, including integers and floating-point numbers.
let count = 10;
let price = 4.99;
console.log(count); // Output: 10
console.log(price); // Output: 4.99
undefined
c. String: Represents a sequence of characters enclosed in single or double quotes. Strings are used to represent textual data.
let message = "Hello, world!";
console.log(message); // Output: Hello, world!
undefined
d. Null: Represents the intentional absence of any object value. It is often assigned to a variable to indicate that it has no value or that the value is unknown.
let value = null;
console.log(value); // Output: null
undefined
e. Undefined: Represents an uninitialized or undeclared variable. If a variable is declared but not assigned a value, it will have the value of undefined.
let variable;
console.log(variable); // Output: undefined
undefined
f. Symbol: Represents a unique identifier. Symbols are typically used as keys in objects to avoid naming conflicts.
let id = Symbol("unique");
console.log(id); // Output: Symbol(unique)
undefined
2. Non-Primitive (Reference) Data Types:
These are mutable data types that store references to memory locations rather than the actual values.