JavaScript ES6+ Interview Questions & Concepts (Destructuring, Spread, Rest)
JavaScript ES6+ Features Explained (Simple & Practical Guide)
If you're working with modern JavaScript or React, ES6+ features are something you simply can’t ignore. These features make your code shorter, cleaner, and much easier to understand. Instead of writing long and repetitive code, ES6 helps you write smart and efficient logic.
ES6+ is not just about new syntax — it’s about writing better and more readable JavaScript.
1. Destructuring
Destructuring lets you take values from objects or arrays and assign them to variables in a clean way. No need to access each property manually again and again.
Object Destructuring
const user = {
name: "Divyansh",
age: 22
};
const { name, age } = user;
console.log(name); // Divyansh
Array Destructuring
const colors = ["red", "blue", "green"];
const [first, second] = colors;
console.log(first); // red
2. Spread Operator (...)
The spread operator is used to expand elements. It's very useful when you want to merge arrays or copy data.
const arr1 = [1, 2];
const arr2 = [3, 4];
const result = [...arr1, ...arr2];
console.log(result); // [1, 2, 3, 4]
3. Rest Operator (...)
The rest operator collects multiple values into a single array. It is commonly used in functions when you don’t know how many arguments will come.
function sum(...numbers) {
return numbers.reduce((total, num) => total + num, 0);
}
console.log(sum(1, 2, 3, 4)); // 10
4. Template Literals
Template literals allow you to write dynamic strings easily using backticks (`). You can directly insert variables without using + operator.
const name = "Divyansh";
const message = `Hello ${name}, welcome!`;
console.log(message);
5. Optional Chaining (?.)
Optional chaining helps you safely access nested properties without breaking your code. If something is undefined, it simply returns undefined instead of throwing an error.
const user = {
profile: {
name: "Divyansh"
}
};
console.log(user?.profile?.name); // Divyansh
console.log(user?.address?.city); // undefined
More In Javascript
Explore more Javascript articles
Read more articles from the same category or open the full category archive directly.
Javascript
JavaScript Basics Explained: Variables, Data Types & Functions with Examples
Javascript
JavaScript Arrays Explained with Examples Part 2 (Complete Beginner Guide)
Javascript
JavaScript Arrays Explained with Examples (Complete Beginner Guide)
Recent Posts
Bharat Ratna Award Winners List 1954 to 2024: History, Facts and Full List
26 March 2026
Nobel Prize 2025 Winners, History, Categories, Indian Winners & Important Facts (Hindi + English)
26 March 2026
JavaScript Basics Explained: Variables, Data Types & Functions with Examples
21 March 2026
JavaScript Arrays Explained with Examples Part 2 (Complete Beginner Guide)
20 March 2026
JavaScript Arrays Explained with Examples (Complete Beginner Guide)
20 March 2026
Callback vs Promises in JavaScript
20 March 2026
Async/Await Error Handling in JavaScript
20 March 2026
Javascript Array Methods Reduce Filter Includes Find findindex Sort
17 March 2026
JavaScript Array Methods Explained with Examples
17 March 2026
Core React Interview Questions Every Developer Should Know
16 March 2026