JavaScript Interview

Advanced JavaScript, Practical Problems & Senior Interview Scenarios

Advanced JavaScript interview questions covering functional programming, numeric precision, regular expressions, metaprogramming, practical coding problems, concurrency, caching, race conditions and production architecture.

25 Questions Filter by level

Interview questions

Open a question for the full answer, code and interview guidance.

25 Results
176
SeniorAdvanced

What is functional programming in JavaScript?

Functional programming is a style of programming that emphasizes functions, expressions, immutability, composition, and minimizing shared mutable state. JavaScript supports this style because functions are first-class values and can be passed, returned, and composed.

177
SeniorAdvanced

What is a pure function?

A pure function produces the same output for the same inputs and does not create observable side effects outside the function. It does not depend on hidden mutable state such as a changing global variable.

178
SeniorAdvanced

What are side effects in JavaScript?

A side effect is an observable interaction beyond returning a value. Examples include modifying global state, mutating an external object, changing the DOM, writing storage, logging, making a network request, or starting a timer.

179
SeniorAdvanced

What is immutability, and why is it useful?

Immutability means treating existing values or data structures as unchanged and producing new values for updates. Primitive JavaScript values are immutable, while objects and arrays are mutable by default.

180
SeniorAdvanced

What is function composition?

Function composition combines smaller functions so the output of one becomes the input of another. It encourages small focused transformations that can be tested independently and assembled into more complex behavior.

181
SeniorAdvanced

What is the difference between imperative and declarative JavaScript?

Imperative code describes the individual steps required to achieve a result. Declarative code focuses more on describing the desired transformation or outcome.

182
SeniorAdvanced

What is BigInt in JavaScript?

BigInt is a primitive numeric type for integers that may exceed the safe integer range of the Number type. A BigInt literal is commonly written with an n suffix.

183
SeniorAdvanced

What is Number.MAX_SAFE_INTEGER?

Number.MAX_SAFE_INTEGER is the largest integer that JavaScript's Number type can represent while reliably distinguishing consecutive integers. Its value is 2^53 - 1.

184
SeniorAdvanced

Why can floating-point arithmetic produce unexpected results?

JavaScript Number values use IEEE 754 binary floating-point representation. Many decimal fractions cannot be represented exactly in binary, so arithmetic can contain small rounding errors.

185
SeniorAdvanced

What is Number.EPSILON?

Number.EPSILON is the difference between 1 and the next representable Number value greater than 1. It is useful for understanding floating-point precision and can help in some approximate comparisons.

186
SeniorAdvanced

What are regular expressions in JavaScript?

A regular expression describes a text pattern used for searching, matching, validation, extraction, and replacement. JavaScript supports regex literals and the RegExp constructor.

187
SeniorAdvanced

What is the difference between test(), match(), and exec() for regular expressions?

RegExp.test returns a Boolean indicating whether a pattern matches. String.match returns match information, with behavior affected by flags such as g. RegExp.exec returns detailed information for the next match and can be used repeatedly with stateful global or sticky regular expressions.

188
SeniorAdvanced

What are Proxy and Reflect in JavaScript?

Proxy allows code to intercept fundamental operations performed on an object, such as property access, assignment, deletion, or key enumeration. Reflect provides standardized functions corresponding to many of those internal operations.

189
SeniorAdvanced

What is metaprogramming in JavaScript?

Metaprogramming is code that inspects, modifies, or controls the behavior or structure of other code and objects. JavaScript supports metaprogramming through features such as property descriptors, symbols, Proxy, Reflect, and dynamic property access.

190
SeniorAdvanced

What is the difference between Map, WeakMap, Object, and Set?

Object is well suited to record-like data with named properties. Map is a dedicated key-value collection that supports keys of any type, iteration, and a size property. Set stores unique values rather than key-value pairs.

191
SeniorAdvanced

How would you remove duplicate objects from an array by a property?

A common solution is to use a Map keyed by the property that defines uniqueness. This makes the intended uniqueness rule explicit and can preserve either the first or last occurrence depending on how the algorithm is written.

192
SeniorAdvanced

How would you group an array of objects by a property?

Grouping converts a flat collection into groups based on a key such as category, status, or department. It can be implemented with reduce and an object or Map, and modern environments may also provide grouping APIs depending on the supported runtime.

193
SeniorAdvanced

How would you flatten a nested array?

JavaScript arrays provide flat(depth), which returns a new array with nested arrays flattened up to the specified depth. Infinity can be used when all nested array levels should be flattened.

194
SeniorAdvanced

How would you implement a simple retry mechanism for an asynchronous operation?

A retry mechanism attempts an operation again after a failure, usually with a maximum number of attempts and often with a delay or backoff strategy. Retries should be limited to failures that are reasonably transient.

195
SeniorAdvanced

How would you limit concurrency when processing many asynchronous operations?

Starting thousands of asynchronous operations at once can overload the browser, server, network, database, or external API. A concurrency limit processes only a controlled number of operations simultaneously.

196
SeniorAdvanced

How would you implement a timeout for a Promise-based operation?

A timeout can be modeled by racing the operation against a Promise that rejects after a specified delay. However, Promise.race alone does not cancel the underlying operation; the original work may continue.

197
SeniorAdvanced

How would you design client-side caching for API data?

Client-side caching should define what is cached, the cache key, freshness duration, invalidation rules, error behavior, and whether stale data may be served while refreshing. A simple in-memory Map can be appropriate for short-lived page data, while persistent storage has different tradeoffs.

198
SeniorAdvanced

How should JavaScript applications handle race conditions in UI requests?

A UI race condition can occur when multiple asynchronous requests are in flight and an older request finishes after a newer one, overwriting the latest state. Search-as-you-type interfaces are a common example.

199
SeniorAdvanced

What JavaScript topics should a senior developer understand for debugging production issues?

A senior developer should understand scope and closures, this binding, prototypes, asynchronous execution, Promise error propagation, the event loop, browser rendering, memory reachability, network behavior, DOM events, security boundaries, modules, and build output.

200
SeniorAdvanced

How would you structure JavaScript for a maintainable production application?

A maintainable application separates responsibilities into clear modules and keeps dependencies explicit. Domain calculations should be separated from DOM manipulation, network access, storage, and other infrastructure where practical. State ownership and data flow should be understandable rather than spread across unrelated global variables.