All Posts

Top 30 JavaScript & TypeScript Interview Questions 2026 - Real Battle with detailed answers

technologyFebruary 12, 2026·#Technology

Explore 30 common JavaScript & TypeScript interview questions in 2026. Prepare a solid language foundation, type system and problem-solving mindset to confidently pass the technical interview.

Top 30 JavaScript & TypeScript Interview Questions 2026 - Real Battle with detailed answers

Compilation of the latest JavaScript and TypeScript interview questions in 2026 with detailed answers. Help Frontend Developer confidently pass the technical interview round.

  1. What is Virtual DOM? What algorithm does React use to diff between renders?

  2. When typing a quick search causes mixed results, how to handle it? (race condition)

  3. How to cache search results so they don't re-fetch?

  4. What is the difference between Type and Interface

  5. Generic?

  6. How do mapped types like Partial, Required,... work?

  7. Limit points enum mechanism in TypeScript

  1. How does Event Loop work? Microtask vs Macrotask?

  2. What is Closure? Give real-life examples where closures cause bugs or memory issues. How does

  3. this in JavaScript work? What is the difference between arrow function and regular function?

  4. Prototype and Prototype Chain? What does it mean that JavaScript is prototype-based?

  5. Deep copy vs Shallow copy — when causes production bugs?

  6. Debounce vs Throttle — different and in what cases?

  7. Promise vs Async/Await — does async/await make code synchronous?

  8. Ways handle error in async code? (try/catch, .catch, global handler)

  1. unknown vs any — which one to use and why?

  2. Union vs Intersection types — what's the difference?

  3. never What is it? When does TypeScript infer the type never?

  4. keyof and what is typeof for?

  5. What is type narrowing / type guards? For example (in, typeof, instanceof).

See more: Interview Questions Next.js 2026 Advanced

After many recent Frontend interviews, I realized a very clear truth:

Framework can help you get called for an interview.
But JavaScript and TypeScript are what decide whether you pass or fail.

Many developers learn React, NextJS very quickly — but lack the foundation of how JavaScript actually works. practice.

And that's what the interviewer wants to test.

Note: This is not a list to memorize.
The questions below are often used to:

  • measure depth of knowledge

  • assess technical thinking

  • developer level classification

If you master this section, you have passed most of the round technical.

1. What is Virtual DOM? Diffing algorithm?

DOM

Algorithm:

React uses heuristic O(n) instead of O(n³).

Two main assumptions:

  • Element of different type → replace entire subtree

  • Use key to identify elements in list

2. Race condition when searching

Occurs when the request is sent first but the response comes later.

Best way to handle:

AbortController

const controller = new AbortController();
fetch(url, { signal: controller.signal });
controller.abort();

Track request id
Only update UI if response is the latest request.

React Query / SWR
This library preprocesses it.

3. Cache search results

Goal: avoid API calls again.

Common way:

Map / Object

const cache = new Map();

if(cache.has(query)) return cache.get(query);

Library: React Query, SWR → auto cache + revalidate.

Advanced:

  • LRU cache

  • TTL (time expiration)

4. Type vs Interface

Interface

  • Extend easily

  • Declaration merging

  • Good for object / class

Type

  • Union, intersection

  • More flexible

5. What is Generic?

Allows you to write reusable code while still maintaining type safety.

function identity(value: T): T {
  return value;
}

Use case senior:

  • API response wrapper

  • Repository pattern

  • Custom hooks

Keyword should say:
reusable + type-safe

6. Mapped Types

Allows to create new types from old types.

Partial example:

type Partial = {
  [P in keyof T]?: T[P];
};

Common:

  • Partial → optional

  • Required → required

  • Readonly

  • Pick / Omit

Shows you understand type transformation.

7. Limitations of enum

  • Creating runtime objects → increasing bundle

  • Difficulty in tree-shaking

  • Not flexible

Modern trends:

type Role = "admin" | "user";

Lighter + safer.

8. Event Loop

JS is single-threaded but handles async thanks to event loop.

Flow:

  1. Call stack runs sync

  2. Async → Web APIs

  3. Callback → Queue

  4. Event loop pushed in stack

Microtask has priority over Macrotask:

Microtask:

  • Promise

  • queueMicrotask

Macrotask:

  • setTimeout

  • setInterval

Trick: Promise runs first setTimeout.

9. Closure

Function remembers the outer scope even if the scope has ended.

function counter() {
  let count = 0;
  return () => ++count;
}

Causing bugs when:

  • Keeping large references → memory leak

  • Loop with var

Fix with let.

10. How does this work?

Depends on how the function is called, not where it is written.

Quick rule:

  • Method → ​​this = object

  • Arrow → don't bind this

  • call/apply/bind → set manually

11. Prototype Chain

JS is not class-based — but prototype-based.

When accessing property:

  • Search in object

  • None → go to prototype

  • Until null

12. Deep vs Shallow copy

Shallow: copy reference nested object.

{...obj}

Deep:

structuredClone(obj)

13. Debounce vs Throttle

Debounce: runs only after the user stops typing.

Throttle: limits the number of runs by interval.

Search → debounce
Scroll → throttle

14. Promise vs Async/Await

Async/await is just syntax sugar of Promise.

Does not make code synchronous — still async.

Advantages:

  • Easy to read

  • Try/catch

15. Handle error async

✔ try/catch
.catch()
✔ Global handler

16. unknown vs any

any: turn off type checking
unknown: must check before using.

Always prefer unknown.

17. Union vs Intersection

Union (|) → one of the types
Intersection (&) → must have all

Intersection easily creates conflicts.

18. never

Type of value never occurs.

For example:

  • Function throw error

  • Infinite loop

Used for exhaustive checking in switch.

19. keyof & typeof

keyof: get the key of the object into union type.

type Keys = keyof User;

typeof: get type from variable.

Very powerful when building reusable types.

20. Type Guards / Narrowing

Helps students understand type more specifically.

For example:

if(typeof value === "string") {
}

Or:

  • in

  • instanceof

  • custom guard

There is a very clear pattern:

If you answer topics like Event Loop, Closure or Generics in depth, the interviewer will almost immediately increase the difficulty — because they know you're not just memorizing.

If You Only Have 3–5 Days to Prepare for an Interview

Prioritize in order:

Event Loop
Closure
this
Generics
unknown vs any

Master these 5 topics, you have surpassed most candidates.

Share

Comments

0.0 / 5(0 ratings)

Please login to leave a comment.

No comments yet. Be the first to share your thoughts.