1. What are the different data types in JavaScript?
Primitive: string, number, boolean, null, undefined, symbol, bigint. Non-primitive: object, array,
function.
2. Difference between var, let, and const?
var: function-scoped, hoisted, can re-declare. let: block-scoped, cannot re-declare in same scope.
const: block-scoped, cannot reassign.
3. What is hoisting?
Moving variable and function declarations to the top before execution.
4. Difference between == and ===?
== compares only value (type coercion). === compares value + type.
5. What are closures?
Function that remembers outer scope variables even after outer function ends.
6. Difference between null and undefined?
undefined: variable declared but not assigned. null: intentional empty value.
7. What is event bubbling and capturing?
Bubbling: child → parent. Capturing: parent → child.
8. What are promises?
Promises handle async ops with states: pending, fulfilled, rejected.
9. What is async/await?
Syntactic sugar for promises, makes async look synchronous.
10. Function declaration vs function expression?
Declaration: hoisted. Expression: not hoisted.
11. Difference between for...in and for...of?
for...in: iterates keys. for...of: iterates values.
12. What are arrow functions?
Short syntax, no own 'this'.
13. Synchronous vs Asynchronous JS?
Sync: executes line by line (blocking). Async: non-blocking (e.g., fetch).
14. Deep copy vs Shallow copy?
Shallow copy: only first level. Deep copy: complete independent copy.
15. Difference between map, filter, forEach?
map: returns new array. filter: new array of matches. forEach: loops only.
16. Synchronous vs Asynchronous callbacks?
Sync: runs immediately. Async: runs later (setTimeout).
17. localStorage vs sessionStorage vs cookies?
localStorage: no expiry. sessionStorage: clears on tab close. cookies: small, sent with requests.
18. Higher-order functions?
Functions taking/returning other functions (map, filter, reduce).
19. What is 'this'?
Depends on context: object method → object, global → window, arrow → parent scope.
20. Difference between call, apply, bind?
call: args individually. apply: args as array. bind: returns new function with bound this.