← All interview questions

Skill Zuno · skillzunos.com · Fullstack

JavaScript Design Patterns interview questions

Prepare for JavaScript Design Patterns interviews on Skill Zuno. This practice book covers JavaScript Design Patterns interview questions across New, Easy, Medium, Hard, and Diff levels so you can work through real interview-style problems on skillzunos.com.

Open JavaScript Design Patterns on Skill Zuno

Also see the JavaScript Design Patterns tutorial.

Design patterns in JavaScript take advantage of first-class functions, closures, prototypes and ES modules. Many classic patterns become simpler, and JavaScript adds its own: the module pattern, middleware chains, event emitters and higher-order functions. Interviews cover module, singleton, observer, factory, proxy and decorator patterns, plus patterns used in React and Node.js.

Sample JavaScript Design Patterns interview questions

What is the module pattern?

The module pattern uses a closure, originally an immediately invoked function, to keep variables private and return only a public API. ES modules now give the same encapsulation natively: anything not exported is private.

How do you create a singleton in JavaScript?

Export an instance from an ES module. Modules are evaluated once and cached, so every import receives the same object, with no getInstance() method needed.

What is the difference between observer and publish/subscribe?

In observer, the subject keeps a list of observers and notifies them directly. In pub/sub, publishers and subscribers only know a broker or event channel, which decouples them further.

What can a JavaScript Proxy be used for?

A Proxy intercepts operations such as get, set and delete on an object. It is used for validation, logging, default values and reactivity; Vue 3's reactivity system is built on it.

What is a higher-order function and how does it relate to the decorator pattern?

A higher-order function takes or returns a function. Wrapping a function to add behaviour, such as const logged = withLogging(fetchUser), is the decorator pattern without classes.

What you can practice

  • JavaScript Design Patterns interview questions for beginners and experienced developers
  • Level-based practice: New, Easy, Medium, Hard, and Diff
  • Fullstack topics alongside JavaScript Design Patterns on skillzunos.com

More Fullstack interview questions

All interview questions