important ES6 interview questions

🔰 Basic ES6 Interview Questions

1. What is ES6?

👉 ES6 (ECMAScript 2015) is the 6th version of JavaScript with modern features like let, const, arrow functions, etc.


2. Difference between var, let, and const?

Featurevarletconst
ScopeFunctionBlockBlock
Reassign✅✅❌
HoistingYesYes (TDZ)Yes (TDZ)

3. What is Temporal Dead Zone (TDZ)?

👉 Time between variable declaration and initialization where access causes error.

console.log(a); // ❌ error
let a = 10;

4. What are arrow functions?

👉 Short syntax for functions and no this binding.


5. Difference between normal function and arrow function?

👉 Arrow functions:

  • No this
  • No arguments
  • Cannot be used as constructor

🔥 Intermediate Questions

6. What is destructuring?

👉 Extract values from arrays/objects.

let {name} = {name: "Aditya"};

7. What is spread operator?

👉 Expands values.

let arr = [...[1,2,3]];

8. What is rest operator?

👉 Collects values.

function sum(...nums) {}

9. Difference between spread and rest?

👉 Spread = expand
👉 Rest = collect


10. What are template literals?

👉 Backticks (`) used for dynamic strings.


11. What are default parameters?

function greet(name = "Guest") {}

12. What are modules in ES6?

👉 Split code using import and export


🚀 Advanced ES6 Questions

13. What is this behavior in arrow functions?

👉 Arrow functions inherit this from parent scope.


14. Can we use arrow function as constructor?

👉 ❌ No


15. What is Symbol in ES6?

👉 Unique and immutable data type.

let id = Symbol("id");

16. What are iterators?

👉 Objects that allow looping (next() method).


17. What are generators?

👉 Functions that pause using yield.

function* gen() {
yield 1;
}

18. What is Map in ES6?

👉 Key-value collection (any type key allowed)


19. What is Set?

👉 Collection of unique values


20. Difference between Map and Object?

MapObject
Any key typeString keys
OrderedNot guaranteed
Better performanceLess efficient

💡 Coding-Based Questions

21. Swap variables using ES6

let a = 1, b = 2;
[a, b] = [b, a];

22. Merge arrays

let arr = [...arr1, ...arr2];

23. Clone object

let newObj = {...oldObj};

🎯 Pro Tip for Interview

👉 Most asked topics:

  • let vs const vs var
  • Arrow functions & this
  • Destructuring
  • Spread vs Rest
  • Modules