DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
← From Beginner to Expert in Fundamentals of Frontend
  • Scope & Closures
  • Asynchronous JavaScript
  • DOM Manipulation
  • ES6+ to 2026
  • Execution Context & Call Stack
  • Hoisting: var, let, const & Functions
  • Data Types & Type Coercion
  • Prototypes & the this Keyword
  • The Event Loop Deep Dive
  • Higher-Order Functions, Currying & Functional Patterns
  • Callbacks, Promises & Async/Await
  • Event Delegation & DOM Optimization
  • Destructuring, Spread/Rest & Modern Syntax
  • ES Modules & the Fetch API
  • Memory Management & Garbage Collection
  • Debouncing, Throttling & Performance Patterns
  • Design Patterns in JavaScript
  • Proxies, Reflect & Symbols
  • JavaScript Optimizations & Best Practices
  • JavaScript Interview Questions (30 MCQs)
← From Beginner to Expert in Fundamentals of Frontend

JavaScript Interview Questions (30 MCQs)

30 min read
Interview QuestionsClosuresEvent LoopPrototypesAsync/AwaitMap vs ObjectStrict ModeMemoization

30 Essential JavaScript Interview Questions

1. null vs undefined

Featurenullundefined
MeaningIntentional absence of valueVariable declared but not assigned
typeof"object" (bug)"undefined"
==null == undefined → trueSame
===null === undefined → falseDifferent types
JSONSerializable (null)Omitted from JSON

2. What is a Closure?

A closure is a function that retains access to its lexical scope even when executed outside that scope.

function createCounter() {
  let count = 0;
  return {
    increment: () => ++count,
    getCount: () => count,
  };
}
const counter = createCounter();
counter.increment(); // 1
counter.getCount();  // 1

3. Temporal Dead Zone

The period between entering a scope and the point where a let/const variable is declared. Accessing it throws ReferenceError.

4. call() vs apply() vs bind()

MethodInvokes?Args Format
call(ctx, a, b)Yes, immediatelyComma-separated
apply(ctx, [a, b])Yes, immediatelyArray
bind(ctx, a, b)No, returns new fnComma-separated

5. Prototypal Inheritance

Objects delegate to other objects via the prototype chain. When a property isn't found on an object, JS looks up its __proto__ chain until it finds it or reaches null.

6. Event Loop

See the dedicated lesson. Key: Sync → Microtasks (all) → 1 Macrotask → Microtasks (all) → Render → Repeat.

7. Shallow vs Deep Copy

MethodTypeHandles Nested?
Object.assign()Shallow❌
{...obj}Shallow❌
JSON.parse(JSON.stringify())Deep❌ (loses functions, dates, undefined)
structuredClone()Deep✅ (modern, handles most types)

8. Map vs Object

FeatureMapObject
Key typesAny (objects, functions)String/Symbol only
OrderInsertion order guaranteedMostly insertion order
Sizemap.sizeObject.keys(obj).length
PerformanceBetter for frequent add/deleteBetter for static lookups
IterationDirectly iterableNeed Object.entries()

9. IIFEs

(function() {
  // Private scope — variables don't leak
  const secret = 42;
})();
// Modern alternative: ES Modules provide file-level scope

10. How async/await works under the hood

Async functions are transformed into state machines using generators. Each await is a yield point that suspends execution and resumes when the Promise resolves.

11. Event Bubbling vs Capturing

Bubbling: Event goes from target UP to root (default). Capturing: Event goes from root DOWN to target. Use addEventListener("click", fn, true) for capture phase.

12. __proto__ vs prototype

__proto__ is on every object (its parent reference). prototype is only on functions (template for instances).

13. Strict Mode

"use strict";
// Makes JS safer:
// - No undeclared variables
// - No duplicate params
// - No `with` statement
// - `this` is undefined in plain functions (not window)
// - Octal literals throw errors

14–15. Higher-Order Functions & Object.freeze vs Object.seal

MethodAdd PropsDelete PropsModify Values
Object.freeze()❌❌❌ (shallow)
Object.seal()❌❌✅
Object.preventExtensions()❌✅✅

16. innerHTML vs textContent

PropertyParses HTML?XSS Risk?Performance
innerHTMLYes⚠️ YesSlower (re-parses DOM)
textContentNo (plain text)✅ SafeFaster

17–20. Advanced Topics

Deadlocks in JS? Not traditional deadlocks (single-threaded), but microtask starvation can mimic it.

Promise.all vs allSettled: all rejects on first failure; allSettled waits for all and reports each result.

Currying: f(a, b, c) → f(a)(b)(c). Useful for creating specialized functions from general ones.

Memory Leak Detection: Chrome DevTools → Memory → Heap Snapshots → Compare to find growing objects.

21–25. Expert Level

Reflect API: Provides default operations for Proxy traps. Use Reflect.get() instead of target[prop] in proxy handlers.

for...in vs for...of:

LoopIterates OverBest For
for...inKeys (+ inherited)Objects
for...ofValues (iterables)Arrays, Maps, Sets, Strings

26–30. Performance & Patterns

Debounce: Wait until action stops → then execute (search input). Throttle: Execute at most once per interval (scroll events).

WeakMap vs Map: WeakMap keys must be objects and don't prevent GC. Perfect for associating data with DOM elements.

Memoization: Cache function results. Use for pure functions with expensive computation.

Pure Functions: Same input → same output, no side effects. Foundation of functional programming and testable code.

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.