Lead Frontend
​
​
Log inSign up
© 2026 Lead Frontend. Free educational content, provided as is; it may contain errors. Not affiliated with any company or product named on this site.
TermsPrivacyDisclaimerCopyrightLicenses & credits

Quiz

Short-answer trivia on JavaScript, React, HTML, CSS, TypeScript and the web platform.

Progress

0 / 361 completed

​
​
​
Difficulty
​
Category
​
Topic
​
Status
Recommended
Sort

Showing 361 questions

How do you abort a web request using `AbortController` in JavaScript?

Cancelling fetch with signals, timeouts, AbortSignal.any and cleaning up in effects.

Quiz · JavaScript
Medium
6 min

How do you add, remove, and modify HTML elements using JavaScript?

createElement, append, replaceWith, remove, classList, fragments, templates and avoiding innerHTML XSS.

Quiz · JavaScript
Easy
6 min

Are you familiar with styling SVG?

Yes, there are several ways to color shapes (including specifying attributes on the object) using inline CSS, an embedded CSS section, or an external CSS file.

Quiz · CSS
Medium
3 min

How do ARIA live regions work, and how do you announce dynamic updates reliably?

polite vs assertive, status and alert roles, aria-atomic, timing pitfalls and an announcer pattern.

Quiz · HTML
Medium
7 min

What is the consequence of using array indices as the value for `key`s in React?

Why index keys move state and DOM to the wrong rows, and when they are safe.

Quiz · React
Medium
6 min

What is async/await and how does it simplify asynchronous code?

Syntax over promises: sequential vs parallel awaits, error handling, top-level await and pitfalls.

Quiz · JavaScript
Medium
7 min

How do you handle asynchronous data loading in React applications?

Server Components and loaders, query libraries, careful effects, Suspense and use().

Quiz · React
Medium
8 min

What is the back/forward cache (bfcache), and what makes a page ineligible for it?

Instant back navigations, pageshow/pagehide, unload and other blockers, and how to test eligibility.

Quiz · Performance
Medium
7 min

What are the benefits of using currying and partial application?

Reuse, configuration, composition and point-free pipelines, plus the costs.

Quiz · JavaScript
Medium
5 min

What are the benefits of using hooks in React?

Reusable stateful logic, co-location by concern, and no classes.

Quiz · React
Easy
5 min

Explain the concept of a callback function in asynchronous operations

Passing functions to be called later, error-first callbacks, callback hell and inversion of control.

Quiz · JavaScript
Easy
5 min

Can you describe the main difference between a .forEach loop and a .map() loop and why you would pick one versus the other?

To understand the differences between the two, let's look at what each function does.

Quiz · JavaScript
Medium
3 min

Can you explain the difference between coding a website to be responsive versus using a mobile-first strategy?

Note that these two approaches are not exclusive.

Quiz · CSS
Medium
3 min

Can you give an example for destructuring an object or an array?

Destructuring is an expression available in ES6 which enables a succinct and convenient way to extract values of Objects or Arrays and place them into distinct

Quiz · JavaScript
Medium
3 min

Can you give an example of a curry function and why this syntax offers an advantage?

Currying is a pattern where a function with more than one parameter is broken into multiple functions that, when called in series, will accumulate all of the re

Quiz · JavaScript
Medium
3 min

Can you give an example of an @media property other than screen?

Yes, there are four types of @media properties (including screen):

Quiz · CSS
Medium
3 min

Can you offer a use case for the new arrow => function syntax? How does this new syntax differ from other functions?

One obvious benefit of arrow functions is to simplify the syntax needed to create functions, without a need for the function keyword. The this within arrow func

Quiz · JavaScript
Medium
3 min

How do you reliably determine whether an object is empty?

Own keys vs enumerable keys, symbols, prototypes, null and non-plain objects.

Quiz · JavaScript
Easy
4 min

Explain the difference between classical inheritance and prototypal inheritance

Blueprint-copying classes vs live delegation to objects, and where JS classes fit.

Quiz · JavaScript
Easy
5 min

What is clickjacking, and how do you defend against it?

UI redressing via invisible iframes, frame-ancestors vs X-Frame-Options, and legitimate embedding.

Quiz · Security
Medium
6 min

How can closures be used to create private variables?

The module/factory pattern for encapsulation, and how it compares to #private class fields.

Quiz · JavaScript
Easy
5 min

Explain the concept of code coverage and how it can be used to assess test quality

Line, branch and function coverage, what they miss, and mutation testing.

Quiz · JavaScript
Medium
5 min

What is code splitting in a React application?

Dynamic import, lazy and Suspense, route-level splitting and prefetching.

Quiz · React
Medium
6 min

How do you decide where to code-split a large front-end app, and what can go wrong?

Route, component and vendor splitting, request waterfalls, chunk granularity and caching trade-offs.

Quiz · Performance
Medium
9 min

What is the Command pattern and how is it used?

Encapsulating actions as objects for undo/redo, queues, macros and keyboard shortcuts.

Quiz · JavaScript
Medium
6 min

What are some common security headers and their purpose?

CSP, HSTS, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, COOP and friends.

Quiz · Security
Medium
7 min

What are the common pitfalls of using the `this` keyword?

Lost receivers, callbacks, nested functions, arrow methods on objects and class field trade-offs.

Quiz · JavaScript
Easy
5 min

Explain the differences between CommonJS modules and ES modules in JavaScript

Static imports vs runtime require, live bindings, loading semantics, tree-shaking and interop in Node.

Quiz · JavaScript
Medium
8 min

Consider HTML5 as an open web platform. What are the building blocks of HTML5?

- Semantics - Allowing you to describe more precisely what your content is.

Quiz · HTML
Medium
3 min

How do you validate form elements using the Constraint Validation API?

Native form validation with ValidityState, setCustomValidity and accessible custom error UI.

Quiz · Web & Browser
Hard
8 min

How would you design and roll out a Content Security Policy for an existing production app?

Strict nonce-based CSP, strict-dynamic, report-only rollout, reporting, and the directives that matter.

Quiz · Security
Hard
11 min

How do content-visibility and CSS containment improve rendering performance, and what can go wrong?

contain values, content-visibility: auto, contain-intrinsic-size, and effects on scrollbars, find-in-page and a11y.

Quiz · CSS
Hard
8 min

What is the difference between controlled and uncontrolled React components?

Who owns the value, React state or the DOM, and the trade-offs of each.

Quiz · React
Easy
6 min

How do you convert a Set to an array in JavaScript?

Spread, Array.from and when you might not need to convert at all.

Quiz · JavaScript
Easy
4 min

What are the Core Web Vitals today, how are they measured, and what are the thresholds?

LCP, INP and CLS: what each one captures, the p75 thresholds, and lab vs field data.

Quiz · Performance
Medium
8 min

When does the browser send a CORS preflight, and how do credentialed cross-origin requests work?

Simple vs preflighted requests, the response headers involved, credentials mode, caching preflights and debugging.

Quiz · Web & Browser
Medium
9 min

What are the most common misconceptions about CORS as a security mechanism?

Why CORS relaxes rather than adds protection, origin reflection bugs, null origins and what actually protects APIs.

Quiz · Security
Hard
9 min

Create a for loop that iterates up to 100 while outputting **"fizz"** at multiples of 3, **"buzz"** at multiples of 5 and **"fizzbuzz"** at multiples of 3 and 5.

Check out this version of FizzBuzz by Paul Irish.

Quiz · JavaScript
Medium
3 min

Walk through the critical rendering path. What blocks rendering, and how do you shorten it?

HTML parsing, CSSOM, render-blocking vs parser-blocking resources, the preload scanner and first paint.

Quiz · Web & Browser
Medium
9 min

Compare CSR, SSR, SSG, ISR and streaming SSR. How do you choose a rendering strategy per page?

Trade-offs in TTFB, LCP, INP, freshness, cost and complexity, with a per-route decision framework.

Quiz · Web & Browser
Hard
11 min

What is CSRF, and is SameSite=Lax enough to prevent it in 2025?

How CSRF works, SameSite modes and browser defaults, same-site vs same-origin, and layered defences.

Quiz · Security
Hard
10 min

What are CSS cascade layers (@layer), and how would you use them to tame specificity in a large codebase?

Layer order vs specificity, unlayered styles, !important inversion, and layering resets, libraries and utilities.

Quiz · CSS
Hard
8 min

What are CSS container queries, and how do they change component design compared with media queries?

container-type, named containers, container query units, style queries and the containment trade-offs.

Quiz · CSS
Medium
8 min

How do CSS custom properties differ from Sass/Less variables, and how would you use them for theming?

Runtime vs compile-time, inheritance and scoping, @property typing, fallbacks and design-token architecture.

Quiz · CSS
Medium
8 min

What does the CSS :has() selector enable, and what are its performance and specificity gotchas?

The "parent selector", state-driven styling without JS, quantity queries, specificity and invalidation cost.

Quiz · CSS
Medium
7 min

What are CSS logical properties, and why do they matter for internationalised products?

Inline/block axes, writing modes, RTL support without overrides, and migration strategy.

Quiz · CSS
Easy
6 min

Provide some examples of how currying and partial application can be used

Practical uses: event handlers, loggers, validators, API clients and pipelines.

Quiz · JavaScript
Easy
6 min

How do currying and partial application differ from each other?

Unary chains versus fixing some arguments once, with implementations of both.

Quiz · JavaScript
Medium
5 min

How can you create custom error objects?

Subclassing Error with name, code and cause, and the instanceof caveats.

Quiz · JavaScript
Medium
6 min

Explain the concept of debouncing and throttling

Run after activity stops versus at most once per interval, with implementations and use cases.

Quiz · Performance
Easy
6 min

How do you debug React applications?

DevTools, the Profiler, Strict Mode, lint rules and production error reporting.

Quiz · React
Medium
7 min

What is the Decorator pattern and how is it used?

Wrapping objects or functions to add behaviour, including higher-order functions and TC39 decorators.

Quiz · JavaScript
Medium
6 min

Describe Block Formatting Context (BFC) and how it works.

A Block Formatting Context (BFC) is part of the visual CSS rendering of a web page in which block boxes are laid out. Floats, absolutely positioned elements, in

Quiz · CSS
Medium
3 min

Describe event bubbling.

When an event triggers on a DOM element, it will attempt to handle the event if there is a listener attached, then the event is bubbled up to its parent and the

Quiz · JavaScript
Medium
3 min

Describe event capturing in JavaScript and browsers

The top-down phase of DOM event propagation and when listening in it is useful.

Quiz · JavaScript
Easy
5 min

Describe floats and how they work.

Float is a CSS positioning property. Floated elements remain a part of the flow of the page, and will affect the positioning of other elements (e.g. text will f

Quiz · CSS
Medium
3 min

Describe pseudo-elements and discuss what they are used for.

A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected element(s). They can be used for decoration (:first-li

Quiz · CSS
Medium
3 min

Describe the difference between a cookie, sessionStorage and localStorage.

All the above-mentioned technologies are key-value storage mechanisms on the client side. They are only able to store values as strings.

Quiz · HTML
Medium
3 min

Describe the difference between <script>, <script async> and <script defer>.

- <script - HTML parsing is blocked, the script is fetched and executed immediately, HTML parsing resumes after the script is executed.

Quiz · HTML
Medium
3 min

Describe what you like and dislike about the CSS preprocessors you have used.

- Mostly the advantages mentioned above.

Quiz · CSS
Medium
3 min

Describe z-index and how stacking context is formed.

The z-index property in CSS controls the vertical stacking order of elements that overlap. z-index only affects elements that have a position value which is not

Quiz · CSS
Medium
3 min

What are design patterns and why are they useful?

Reusable solutions to recurring design problems and a shared vocabulary for teams.

Quiz · JavaScript
Easy
5 min

How do you detect if JavaScript is disabled on a page?

noscript, the no-js class swap, the scripting media feature, and progressive enhancement.

Quiz · Web & Browser
Medium
4 min

Difference between document load event and document DOMContentLoaded event?

The DOMContentLoaded event is fired when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes

Quiz · JavaScript
Medium
3 min

Difference between: function Person(){}, var person = Person(), and var person = new Person()?

This question is pretty vague. My best guess at its intention is that it is asking about constructors in JavaScript. Technically speaking, function Person(){} i

Quiz · JavaScript
Medium
3 min

How do you handle errors in asynchronous operations?

try/catch with await, .catch, unhandled rejections, fetch HTTP errors, aggregation and retries.

Quiz · JavaScript
Easy
7 min

Explain the concept of error propagation in JavaScript

How errors unwind the call stack, flow through promise chains and reach global handlers.

Quiz · JavaScript
Medium
6 min

ES6 Template Literals offer a lot of flexibility in generating strings, can you give an example?

Template literals help make it simple to do string interpolation, or to include variables in a string. Before ES2015, it was common to do something like this:

Quiz · JavaScript
Medium
3 min

What are event listeners and how are they used?

addEventListener options (capture, once, passive, signal), removal and memory hygiene.

Quiz · JavaScript
Easy
5 min

Explain the event phases in a browser

Capture, target and bubble phases, eventPhase values, and how shadow DOM retargeting fits in.

Quiz · JavaScript
Medium
6 min

Explain Ajax in as much detail as possible.

Ajax (asynchronous JavaScript and XML) is a set of web development techniques using many web technologies on the client side to create asynchronous web applicat

Quiz · JavaScript
Medium
3 min

Explain CSS sprites, and how you would implement them on a page or site.

CSS sprites combine multiple images into one single larger image. It is a commonly-used technique for icons (Gmail uses it). How to implement it:

Quiz · CSS
Medium
3 min

Explain event delegation

Event delegation is a technique involving adding event listeners to a parent element instead of adding them to the descendant elements. The listener will fire w

Quiz · JavaScript
Medium
3 min

What is the event loop? Explain the difference between the macrotask and microtask queues.

How JavaScript schedules callbacks, promises and rendering on a single thread.

Quiz · JavaScript
Medium
8 min

Explain Function.prototype.bind.

The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any pro

Quiz · JavaScript
Medium
3 min

Explain "hoisting".

Hoisting is a term used to explain the behavior of variable declarations in your code. Variables declared or initialized with the var keyword will have their de

Quiz · JavaScript
Medium
3 min

Explain how a browser determines what elements match a CSS selector.

This part is related to the above about writing efficient CSS(what-are-some-of-the-gotchas-for-writing-efficient-css). Browsers match selectors from rightmost (

Quiz · CSS
Medium
3 min

Explain how JSONP works (and how it's not really Ajax).

JSONP (JSON with Padding) is a method commonly used to bypass the cross-domain policies in web browsers because Ajax requests from the current page to a cross-o

Quiz · JavaScript
Medium
3 min

Explain how prototypal inheritance works

All JavaScript objects have a proto property with the exception of objects created with Object.create(null), that is a reference to another object, which is cal

Quiz · JavaScript
Medium
3 min

Explain how this works in JavaScript

There's no simple explanation for this; it is one of the most confusing concepts in JavaScript. A hand-wavey explanation is that the value of this depends on ho

Quiz · JavaScript
Medium
3 min

Explain the difference between mutable and immutable objects.

Immutability is a core principle in functional programming, and has lots to offer to object-oriented programs as well. A mutable object is an object whose state

Quiz · JavaScript
Medium
7 min

Explain the difference between synchronous and asynchronous functions.

Synchronous functions are blocking while asynchronous functions are not. In synchronous functions, statements complete before the next statement is run. In this

Quiz · JavaScript
Medium
3 min

Explain the differences on the usage of foo between function foo() {} and var foo = function() {}

The former is a function declaration while the latter is a function expression. The key difference is that function declarations have its body hoisted but the b

Quiz · JavaScript
Medium
3 min

Explain the same-origin policy with regards to JavaScript.

The same-origin policy restricts how a document or script from one origin can interact with resources from another origin. Two URLs have the same origin when th

Quiz · JavaScript
Medium
3 min

Explain what a single page app is and how to make one SEO-friendly.

The below is taken from the awesome Grab Front End Guide, which coincidentally, is written by me!

Quiz · JavaScript
Medium
4 min

Explain why the following doesn't work as an IIFE: function foo(){ }();. What needs to be changed to properly make it an IIFE?

IIFE stands for Immediately Invoked Function Expressions. The JavaScript parser reads function foo(){ }(); as function foo(){ } and ();, where the former is a f

Quiz · JavaScript
Medium
3 min

Explain your understanding of the box model and how you would tell the browser in CSS to render your layout in different box models.

The CSS box model describes the rectangular boxes that are generated for elements in the document tree and laid out according to the visual formatting model. Ea

Quiz · CSS
Medium
3 min

What is the Factory pattern and how is it used?

Creating objects through a function that hides construction details.

Quiz · JavaScript
Medium
5 min

How do browsers prioritise resource loading, and when should you use the fetchpriority attribute?

Default priorities by resource type, fetchpriority high/low/auto, interaction with lazy loading and preload.

Quiz · HTML
Medium
7 min

What is the first rule of ARIA, and what are the most common ARIA mistakes you see in code reviews?

Native first, ARIA changes semantics not behaviour, and the recurring misuse patterns in component libraries.

Quiz · HTML
Medium
8 min

How do you decide between Flexbox and Grid, and what problem does subgrid solve?

Content-out vs layout-in thinking, intrinsic sizing, auto-fit/minmax, subgrid alignment and accessibility of visual reordering.

Quiz · CSS
Medium
8 min

How do you build fluid typography and spacing with clamp(), and what are the accessibility pitfalls?

Deriving the preferred value, rem + vw mixing for zoom, container units, and WCAG resize requirements.

Quiz · CSS
Medium
7 min

What is the Flux pattern and what are its benefits?

Unidirectional actions, dispatcher and stores, and how Redux evolved from it.

Quiz · React
Medium
6 min

How do you handle errors using try...catch blocks?

How try/catch works with sync and async code, and how to catch errors usefully.

Quiz · JavaScript
Easy
5 min

What are some best practices for handling sensitive data in JavaScript?

What never belongs in the client, token storage, transport, logging and memory hygiene.

Quiz · Security
Medium
7 min

Have you ever used a grid system, and if so, what do you prefer?

Before Flex became popular (around 2014), the float-based grid system was the most reliable because it still has the most browser support among the alternative

Quiz · CSS
Medium
3 min

Have you ever used JavaScript templating? If so, what libraries have you used?

Yes. Handlebars, Underscore, Lodash, AngularJS, and JSX. I disliked templating in AngularJS because it made heavy use of strings in the directives and typos wou

Quiz · JavaScript
Medium
3 min

Have you ever worked with retina graphics? If so, when and what techniques did you use?

Retina is just a marketing term to refer to high resolution screens with a pixel ratio bigger than 1. The key thing to know is that using a pixel ratio means th

Quiz · CSS
Medium
3 min

Have you played around with the new CSS Flexbox or Grid specs?

Yes. Flexbox is mainly meant for 1-dimensional layouts while Grid is meant for 2-dimensional layouts.

Quiz · CSS
Medium
3 min

Have you used different HTML templating languages before?

Yes, Pug (formerly Jade), ERB, Slim, Handlebars, Jinja, Liquid, and EJS just to name a few. In my opinion, they are more or less the same and provide similar fu

Quiz · HTML
Medium
3 min

Have you used or implemented media queries or mobile-specific layouts/CSS?

Yes. An example would be transforming a stacked pill navigation into a fixed-bottom tab navigation beyond a certain breakpoint.

Quiz · CSS
Medium
3 min

How can you share code between files?

This depends on the JavaScript environment.

Quiz · JavaScript
Medium
3 min

How do you organize your code? (module pattern, classical inheritance?)

In the past, I've used Backbone for my models which encourages a more OOP approach, creating Backbone models and attaching methods to them.

Quiz · JavaScript
Medium
3 min

How do you serve a page with content in multiple languages?

I will assume that it is asking about the most common case, which is how to serve a page with content available in multiple languages, but the content within th

Quiz · HTML
Medium
3 min

How do you serve your pages for feature-constrained browsers? What techniques/processes do you use?

- Graceful degradation - The practice of building an application for modern browsers while ensuring it remains functional in older browsers.

Quiz · CSS
Medium
3 min

How does JavaScript garbage collection work?

Reachability, mark-and-sweep, generational collection and how front-end apps leak memory.

Quiz · JavaScript
Hard
7 min

How is responsive design different from adaptive design?

Both responsive and adaptive design attempt to optimize the user experience across different devices, adjusting for different viewport sizes, resolutions, usage

Quiz · CSS
Medium
3 min

How do you create a constructor function?

Writing a constructor, putting methods on the prototype, guarding against missing new, and the class equivalent.

Quiz · JavaScript
Easy
4 min

What causes Cumulative Layout Shift (CLS) and how do you fix it?

Session windows, the usual culprits (images, ads, fonts, injected banners) and how to debug shifts.

Quiz · Performance
Medium
8 min

How do you find and fix a poor INP (Interaction to Next Paint)?

Input delay, processing time and presentation delay: finding the slow interaction and fixing each phase.

Quiz · Performance
Hard
10 min

Your field LCP is 4.1 s on mobile. How do you diagnose and improve it?

Breaking LCP into TTFB, resource load delay, load duration and render delay, and fixing each part.

Quiz · Performance
Hard
10 min

How does virtual DOM in React work? What are its benefits and downsides?

Render, diff with type and key heuristics, commit, and the costs of doing so.

Quiz · React
Medium
7 min

How would you approach fixing browser-specific styling issues?

- After identifying the issue and the offending browser, use a separate style sheet that only loads when that specific browser is being used. This technique req

Quiz · CSS
Medium
3 min

How would you implement a web design comp that uses non-standard fonts?

Use @font-face and define font-family for different font-weights.

Quiz · CSS
Medium
3 min

How does the native <dialog> element work, and what does showModal() give you over a custom modal?

Top layer, inertness, focus handling, Escape, ::backdrop, form method=dialog and remaining gaps.

Quiz · HTML
Medium
8 min

Design an HTTP caching strategy for a web app: Cache-Control, ETag and stale-while-revalidate.

Immutable hashed assets, revalidated HTML, CDN vs browser caches, validators and common caching incidents.

Quiz · Web & Browser
Hard
10 min

How do you make an HTTP request using the Fetch API?

GET and POST with fetch, checking response.ok, timeouts and cancellation.

Quiz · JavaScript
Easy
6 min

What changed from HTTP/1.1 to HTTP/2 to HTTP/3, and what does it mean for front-end delivery?

Multiplexing, HPACK/QPACK, head-of-line blocking, QUIC over UDP, and which old optimisations are now harmful.

Quiz · Web & Browser
Medium
9 min

How do iframes on a page communicate?

Cross-origin messaging with postMessage, origin checks and MessageChannel.

Quiz · Web & Browser
Medium
7 min

How do you safely embed untrusted content with iframe sandboxing?

sandbox tokens, the allow-scripts + allow-same-origin trap, separate origins, allow (Permissions Policy) and srcdoc.

Quiz · Security
Hard
8 min

How would you set up image optimisation for a large, image-heavy site?

Formats, responsive images, lazy loading, priority hints, image CDNs and governance at scale.

Quiz · Performance
Medium
9 min

How do you import and export modules in JavaScript?

Named, default, namespace, re-export and dynamic imports, and live bindings.

Quiz · JavaScript
Easy
5 min

What does the inert attribute do, and when would you use it instead of aria-hidden or tabindex=-1?

Removing subtrees from focus, interaction and the accessibility tree in one attribute, with real use cases.

Quiz · HTML
Medium
6 min

Explain the concept of inheritance in ES2015 classes

extends, super, constructor rules, method overriding, statics and private fields in subclasses.

Quiz · JavaScript
Easy
6 min

What is the difference between innerHTML and textContent?

How markup parsing, text nodes and innerText differ, and why textContent is the safe default.

Quiz · JavaScript
Medium
5 min

Explain the concept of input validation and its importance in security

Server-side allowlist validation with schemas, versus output encoding, and why client checks are UX only.

Quiz · Security
Medium
6 min

Compare IntersectionObserver, ResizeObserver and MutationObserver. When would you use each?

What each observer watches, when callbacks run, performance characteristics and common pitfalls.

Quiz · Web & Browser
Medium
8 min

What is the Intl namespace object for?

Locale-aware formatting of numbers, dates, plurals, lists, collation and segmentation.

Quiz · JavaScript
Medium
6 min

Is there any reason you'd want to use translate() instead of absolute positioning, or vice-versa? And why?

translate() is a value of CSS transform. Changing transform or opacity does not trigger browser reflow or repaint but does trigger compositions; whereas changin

Quiz · CSS
Medium
3 min

What is islands architecture, and how does it compare with full hydration and React Server Components?

Static HTML with isolated interactive islands, hydration directives, resumability, and when islands fit.

Quiz · Web & Browser
Hard
9 min

What are iterators and generators in JavaScript and what are they used for?

The iteration protocols, function*, lazy sequences, async iteration and iterator helpers.

Quiz · JavaScript
Hard
8 min

What are the various data types in JavaScript?

The seven primitives plus objects, typeof quirks, and value vs reference semantics.

Quiz · JavaScript
Easy
5 min

What are the different types of errors in JavaScript?

Built-in Error subclasses, DOMException, and useful ways to categorise failures.

Quiz · JavaScript
Medium
5 min

What are modules and why are they useful?

Scope isolation, explicit dependencies, tree shaking and code splitting with ES modules.

Quiz · JavaScript
Easy
5 min

What are some common performance bottlenecks in JavaScript applications?

Large bundles, long tasks, layout thrashing, memory leaks, network waterfalls and over-rendering.

Quiz · Performance
Medium
7 min

What are some tools that can be used to measure and analyze JavaScript performance?

DevTools Performance panel, Lighthouse, RUM with web-vitals, bundle analysers and profilers.

Quiz · Performance
Hard
6 min

What are some tools and techniques for identifying security vulnerabilities in JavaScript code?

Dependency audits, SAST, secret scanning, DAST, CSP reporting and code review in CI.

Quiz · Security
Medium
6 min

What are some tools that can be used for JavaScript testing?

The wider testing toolbox: runners, DOM utilities, mocking, browsers, visual, a11y and static checks.

Quiz · JavaScript
Easy
5 min

Explain the concept of lazy loading and how it can improve performance

Deferring images, iframes, code and data until needed, and when not to.

Quiz · Performance
Easy
5 min

Explain the concept of lexical scoping

Scope decided by where code is written, the scope chain, and how it enables closures.

Quiz · JavaScript
Easy
5 min

When should you virtualise a long list, how does it work, and what does it cost you?

Windowing mechanics, variable heights, accessibility and find-in-page trade-offs, and alternatives like content-visibility.

Quiz · Performance
Medium
8 min

How do you localize React applications?

Message catalogs, ICU MessageFormat, Intl, locale routing, RTL and translation workflow.

Quiz · React
Medium
7 min

What is a long task, and what are the ways to break one up and yield to the main thread?

The 50 ms rule, setTimeout vs scheduler.yield vs postTask, isInputPending, Workers and the LoAF API.

Quiz · Performance
Hard
10 min

What are some best practices for writing maintainable and effective tests in JavaScript?

Behaviour-focused, deterministic, readable tests that survive refactors.

Quiz · JavaScript
Medium
6 min

Make this work:

Make this work:

Quiz · JavaScript
Medium
3 min

How do you manipulate CSS styles using JavaScript?

Classes, custom properties, inline styles, computed styles and constructable stylesheets.

Quiz · JavaScript
Easy
5 min

What are the differences between `Map`/`Set` and `WeakMap`/`WeakSet` in JavaScript?

Weakly held keys, garbage collection, non-iterability, and real use cases like caches and private data.

Quiz · JavaScript
Easy
6 min

What is the difference between a `Map` object and a plain object in JavaScript?

Key types, ordering, size, prototype pitfalls, performance and serialisation compared.

Quiz · JavaScript
Easy
5 min

How do memory leaks happen in long-lived SPAs, and how would you find one?

Detached DOM, forgotten listeners, timers, caches and closures, plus the heap-snapshot workflow.

Quiz · Performance
Hard
10 min

What are mocks and stubs and how are they used in testing?

Test doubles: stubs, mocks, spies and fakes, plus network mocking with MSW.

Quiz · JavaScript
Hard
6 min

What are the benefits of using a module bundler?

Graph resolution, transforms, minification, code splitting and cache-friendly output.

Quiz · Performance
Medium
6 min

What are the metadata fields of a module?

import.meta.url, import.meta.resolve, host-specific fields and package.json module metadata.

Quiz · JavaScript
Medium
5 min

What is the Module pattern and how does it help with encapsulation?

IIFE closures, revealing module, ES modules and private class fields for encapsulation.

Quiz · JavaScript
Medium
5 min

What is the difference between `mouseenter` and `mouseover` event in JavaScript and browsers?

Why mouseenter does not bubble or fire for children, and when each is the right choice.

Quiz · JavaScript
Easy
4 min

How do you reduce supply-chain risk from npm dependencies in a front-end codebase?

Typosquatting, compromised maintainers, install scripts, lockfiles, provenance and dependency governance.

Quiz · Security
Hard
10 min

What are JavaScript object getters and setters for?

Computed properties, validation and encapsulation with get/set, plus their performance and debugging trade-offs.

Quiz · JavaScript
Medium
5 min

What is `Object.preventExtensions()` for?

Blocking new properties, and how it compares to Object.seal and Object.freeze.

Quiz · JavaScript
Medium
4 min

Explain the Observer pattern and its use cases

Subjects notifying subscribers: event emitters, EventTarget, stores and their pitfalls.

Quiz · JavaScript
Medium
6 min

How can you optimize DOM manipulation for better performance?

Batching reads and writes, fragments, delegation, virtualization and content-visibility.

Quiz · Performance
Hard
7 min

How can you optimize network requests for better performance?

Fewer, smaller, earlier, cached and prioritised requests.

Quiz · Performance
Hard
7 min

How would you optimize the performance of React contexts to reduce rerenders?

Stable values, split contexts, state/dispatch separation and selector-based stores.

Quiz · React
Hard
8 min

Other Answers

- https://github.com/sudheerj/javascript-interview-questions

Quiz · JavaScript
Medium
3 min

Explain the concept of partial application

Fixing some arguments of a function up front to create a more specific function.

Quiz · JavaScript
Medium
5 min

What are the potential pitfalls of using closures?

Loop capture bugs, stale closures in React, retained memory and per-instance function costs.

Quiz · JavaScript
Medium
6 min

What is the Popover API, and when do you use popover instead of a <dialog> or a custom dropdown?

popover=auto/manual, popovertarget, light dismiss, top layer, anchor positioning and accessibility gaps.

Quiz · HTML
Medium
7 min

What are some popular JavaScript testing frameworks?

Vitest, Jest, node:test, Testing Library, Playwright, Cypress and how they fit together.

Quiz · JavaScript
Easy
5 min

Explain preload, prefetch, preconnect, dns-prefetch and modulepreload. When does each help or hurt?

Resource hints, speculation rules and 103 Early Hints, with the costs of over-hinting.

Quiz · Performance
Medium
9 min

Explain the presentational vs container component pattern in React

Separating logic from view, and how hooks and headless libraries changed it.

Quiz · React
Easy
5 min

How do you prevent the default behavior of an event?

preventDefault, cancelable events, passive listeners and when not to block defaults.

Quiz · JavaScript
Easy
4 min

What is the difference between `event.preventDefault()` and `event.stopPropagation()`?

Cancelling the browser action vs stopping the event travelling, plus stopImmediatePropagation.

Quiz · JavaScript
Medium
5 min

How can you prevent SQL injection vulnerabilities in JavaScript applications?

Parameterized queries, ORMs, query builders and least privilege on the Node.js side.

Quiz · Security
Medium
6 min

What are Progressive Web Applications (PWAs)?

Installable, offline-capable web apps built on a manifest, service worker and HTTPS.

Quiz · Web & Browser
Medium
7 min

How is `Promise.all()` different from `Promise.allSettled()`?

Fail-fast vs wait-for-everything, result shapes, and where any and race fit in.

Quiz · JavaScript
Medium
5 min

Explain the different states of a Promise

Pending, fulfilled and rejected, what settled and resolved really mean, and why state is immutable.

Quiz · JavaScript
Medium
5 min

What are JavaScript object property flags and descriptors?

writable, enumerable, configurable, accessor descriptors and how freeze/seal build on them.

Quiz · JavaScript
Hard
7 min

Explain the concept of the Prototype pattern

Creating objects from existing ones: Object.create, prototype sharing and cloning.

Quiz · JavaScript
Easy
5 min

What is the purpose of the finally block?

Cleanup that runs on every exit path, Promise.finally, override gotchas and using declarations.

Quiz · JavaScript
Easy
4 min

What is the purpose of the `key` prop in React?

Keys give list items stable identity for reconciliation and state.

Quiz · React
Easy
5 min

What is the purpose of the `new` keyword?

The four steps new performs, return-value rules, new.target and what cannot be constructed.

Quiz · JavaScript
Easy
5 min

Explain the difference between `document.querySelector()` and `document.getElementById()`

Selector power vs a direct id lookup, scoping, live vs static collections and escaping.

Quiz · JavaScript
Easy
4 min

What are Actions in React 19? Explain `useActionState` and `useFormStatus`

Async transitions for mutations with built-in pending, error and form-reset handling.

Quiz · React
Medium
9 min

How has error handling changed in React 19?

Root error callbacks, de-duplicated logging, Action errors and boundaries.

Quiz · React
Medium
7 min

How do refs work as a prop in React 19, and what are ref cleanup functions?

ref as a regular prop, the end of forwardRef, and callback ref cleanups.

Quiz · React
Medium
6 min

What are some React anti-patterns?

Derived state, effect chains, nested component definitions, mutation and more.

Quiz · React
Medium
8 min

What is the React Compiler and how does it change memoization?

Build-time automatic memoization, its reliance on the Rules of React, and adoption.

Quiz · React
Medium
8 min

Explain the composition pattern in React

children, slots and compound components instead of inheritance and prop explosions.

Quiz · React
Medium
7 min

What are some pitfalls about using context in React?

Re-render cascades, unstable values, overuse and missing providers.

Quiz · React
Medium
7 min

What are some common pitfalls when doing data fetching in React?

Races, missing cleanup, waterfalls, missing caching and stale copies of server data.

Quiz · React
Medium
8 min

What are error boundaries in React for?

Containing render errors with fallback UI, what they miss, and React 19 changes.

Quiz · React
Medium
6 min

What is React Fiber and how is it an improvement over the previous approach?

Incremental, interruptible reconciliation with priorities, the basis of concurrent React.

Quiz · React
Hard
8 min

What is `forwardRef()` in React used for?

Passing refs through components, and why React 19 makes ref a regular prop.

Quiz · React
Medium
5 min

What are React Fragments used for?

Grouping children without extra DOM nodes, keyed fragments, and state preservation.

Quiz · React
Easy
4 min

What are higher-order components in React?

Component-in, component-out wrappers, their conventions, and why hooks replaced most of them.

Quiz · React
Medium
5 min

Explain what React hydration is

How React adopts server-rendered HTML and makes it interactive, and what changed in 18 and 19.

Quiz · React
Medium
7 min

What causes hydration mismatch errors in React and how do you fix them?

Non-deterministic render, client-only APIs, locale, invalid nesting, and the fixes.

Quiz · React
Medium
8 min

What is the difference between React Node, React Element, and a React Component?

Components produce elements; elements are one kind of renderable node.

Quiz · React
Medium
6 min

Explain one-way data flow of React and its benefits

Props down, events up, one owner per piece of state.

Quiz · React
Easy
5 min

What are React Portals used for?

Rendering into another DOM node while staying in the React tree for context and events.

Quiz · React
Medium
5 min

What is reconciliation in React?

How React decides which instances to keep, update or remount, based on type, position and key.

Quiz · React
Medium
7 min

What are render props in React and what are they for?

Function props that delegate rendering, and where they still beat hooks.

Quiz · React
Medium
5 min

What are React Server Components and how do they differ from SSR?

Server-only components that ship no JS, the use client boundary, and how RSC complements SSR.

Quiz · React
Hard
10 min

Explain server-side rendering of React applications and its benefits

Per-request HTML, hydration, streaming SSR and the trade-offs against CSR and SSG.

Quiz · React
Medium
8 min

How do you decide between using React state, context, and external state managers?

Classify state as server, URL, local or shared, then pick the simplest fitting tool.

Quiz · React
Hard
8 min

Explain static generation of React applications and its benefits

Build-time HTML on a CDN, its freshness limits, and ISR-style hybrids.

Quiz · React
Medium
6 min

How does streaming server-side rendering with Suspense work in React?

Shell first, boundaries streamed later, and selective hydration on the client.

Quiz · React
Hard
10 min

What is React Strict Mode and what are its benefits?

Development-only checks: double rendering, effect re-runs, ref checks and deprecation warnings.

Quiz · React
Medium
6 min

What is React Suspense and what does it enable?

Declarative loading boundaries for lazy code, data, streaming SSR and selective hydration.

Quiz · React
Medium
8 min

How does Suspense work for data fetching, and why doesn't it work with `useEffect`?

Suspense-enabled sources, render-as-you-fetch, and cached promises.

Quiz · React
Hard
9 min

What does the `use` API do in React 19 and how is it different from other hooks?

Reading promises and context during render, conditional calls, and the cached-promise rule.

Quiz · React
Medium
7 min

What is the `useCallback` hook in React and when should it be used?

Stable function identities, when they matter, and the React Compiler.

Quiz · React
Medium
6 min

What is the `useId` hook in React and when should it be used?

SSR-safe unique ids for accessibility attributes, and why not for keys.

Quiz · React
Easy
4 min

What is the `useMemo` hook in React and when should it be used?

Caching expensive calculations and stable identities, and when not to bother.

Quiz · React
Medium
6 min

How does `useOptimistic` work in React 19?

Optimistic overlays on real state during Actions, with automatic revert.

Quiz · React
Medium
7 min

What is the `useReducer` hook in React and when should it be used?

Centralized, testable state transitions with a pure reducer and stable dispatch.

Quiz · React
Medium
6 min

What is the `useRef` hook in React and when should it be used?

A persistent mutable box for DOM nodes and values that don't affect rendering.

Quiz · React
Easy
6 min

Explain `useTransition` and `useDeferredValue` and when to use each

Marking updates as non-urgent so concurrent React keeps input responsive.

Quiz · React
Hard
9 min

How do you get the query string values of the current page in JavaScript?

Reading and updating query parameters safely with URLSearchParams and URL.

Quiz · JavaScript
Easy
4 min

How would you build real-user performance monitoring (RUM) with PerformanceObserver?

Entry types, buffered observers, beaconing on visibilitychange, sampling, percentiles and segmentation.

Quiz · Performance
Hard
10 min

How do you redirect to a new page in JavaScript?

location.assign vs replace, router navigation, server redirects and open-redirect safety.

Quiz · Web & Browser
Easy
4 min

Explain reflow (layout), repaint and compositing. How do you avoid layout thrashing and janky animations?

Which CSS changes trigger which pipeline stages, forced synchronous layout, will-change and layer costs.

Quiz · Web & Browser
Medium
9 min

requestAnimationFrame vs requestIdleCallback vs setTimeout: when does each run and what is each for?

Frame-aligned visual work, idle-time background work, deadlines, throttling in background tabs and alternatives.

Quiz · Web & Browser
Medium
7 min

How do you reset a component's state in React?

State follows type plus position; change the key or reset explicitly.

Quiz · React
Medium
6 min

What are the rules of React hooks?

Top-level only, React functions only, why call order matters, and lint enforcement.

Quiz · React
Easy
6 min

Explain the concept of scope in JavaScript

Global, module, function and block scope, the scope chain, shadowing and the temporal dead zone.

Quiz · JavaScript
Easy
6 min

How can you implement secure authentication and authorization in JavaScript applications?

Session cookies vs tokens, OAuth/OIDC with PKCE, passkeys, and server-enforced authorization.

Quiz · Security
Hard
9 min

Why does semantic HTML matter, and how do landmark elements help assistive technology users?

Implicit roles, landmark navigation, headings, buttons vs links, and the cost of div soup.

Quiz · HTML
Easy
7 min

Explain the service worker lifecycle and caching strategies. How do you ship updates without breaking users?

install/waiting/activate, skipWaiting and clients.claim, cache-first vs network-first vs SWR, and update pitfalls.

Quiz · Web & Browser
Hard
11 min

How do Sets and Maps handle equality checks for objects?

SameValueZero and reference identity for object keys, and how to dedupe by value.

Quiz · JavaScript
Easy
5 min

What are Sets and Maps and how are they used?

Unique-value collections and keyed collections with any key type, plus new Set methods.

Quiz · JavaScript
Easy
5 min

What is the purpose of callback function argument format of `setState()` in React and when should it be used?

Updater functions compute next state from the latest queued state.

Quiz · React
Medium
6 min

What is the difference between `setTimeout()`, `setImmediate()`, and `process.nextTick()`?

Where each callback lands in the Node.js event loop, and the browser equivalents.

Quiz · JavaScript
Medium
6 min

Explain the concept of the Singleton pattern

One shared instance, why ES modules already give you one, and the testing downsides.

Quiz · JavaScript
Easy
5 min

How do source maps work, and should you ship them to production?

Mappings, sourcesContent, hidden source maps, uploading to error trackers, and the security trade-offs.

Quiz · Web & Browser
Medium
7 min

What is the difference between state and props in React?

Props are inputs owned by the parent; state is memory owned by the component.

Quiz · React
Easy
5 min

Explain the concept of the Strategy pattern

Swapping interchangeable algorithms behind one interface, often as a map of functions.

Quiz · JavaScript
Medium
5 min

Why do my effects run twice in development, and how should I fix it?

Strict Mode's mount-unmount-mount check and how to write symmetric cleanups.

Quiz · React
Easy
6 min

What is Subresource Integrity (SRI), and how do you manage the risk of third-party scripts?

Integrity hashes, crossorigin, why SRI doesn't fit evergreen tags, and isolation strategies for third parties.

Quiz · Security
Medium
8 min

Explain the concept of test-driven development (TDD)

Red-green-refactor, its benefits, costs and where it fits in front-end work.

Quiz · JavaScript
Medium
5 min

How can you test asynchronous code in JavaScript?

Awaiting promises, asserting rejections, fake timers and waiting for UI updates.

Quiz · JavaScript
Medium
6 min

How do you test React applications?

A layered strategy built on Testing Library, user-event, MSW and E2E tests.

Quiz · React
Medium
8 min

Explain the concept of `this` binding in event handlers

this as currentTarget in listeners, arrows and bind, removing bound listeners and handleEvent objects.

Quiz · JavaScript
Easy
5 min

Explain the concept of tree shaking in module bundling

Dead-code elimination of unused exports, side effects, and what defeats it.

Quiz · Performance
Medium
6 min

What are Trusted Types, and how do they help eliminate DOM-based XSS?

Locking down injection sinks with CSP require-trusted-types-for, policies, default policies and rollout.

Quiz · Security
Hard
9 min

What are the different types of testing in software development?

Functional and non-functional test types and how they fit a front-end strategy.

Quiz · JavaScript
Medium
6 min

What is the difference between `any`, `unknown` and `never` in TypeScript?

The escape hatch, the safe top type, and the empty bottom type.

Quiz · TypeScript
Easy
6 min

What does `as const` do in TypeScript?

Const assertions for literal, readonly types and deriving unions from values.

Quiz · TypeScript
Easy
5 min

What are assertion functions in TypeScript?

Functions that narrow by throwing: asserts condition and asserts value is T.

Quiz · TypeScript
Medium
6 min

What are branded (nominal) types in TypeScript and why use them?

Phantom brands that stop same-shape values being mixed up and mark validated data.

Quiz · TypeScript
Medium
6 min

How do access modifiers work in TypeScript classes, and how is `private` different from `#private`?

Compile-time vs runtime privacy, parameter properties, abstract and override.

Quiz · TypeScript
Medium
6 min

What are conditional types and the `infer` keyword in TypeScript?

Type-level branching, pattern matching with infer, and distribution over unions.

Quiz · TypeScript
Hard
9 min

What are `const` type parameters in TypeScript 5.0?

as const-style literal inference without caller ceremony.

Quiz · TypeScript
Medium
5 min

What are `.d.ts` declaration files and when do you write them?

Types-only files for JS code, assets and globals, and how packages ship types.

Quiz · TypeScript
Medium
7 min

What is declaration merging in TypeScript?

How interfaces, namespaces and enums merge, and how that powers global and module augmentation.

Quiz · TypeScript
Medium
6 min

How do decorators work in TypeScript, and how do standard decorators differ from experimental ones?

TS 5.0 standard decorators vs legacy experimentalDecorators, and their use cases.

Quiz · TypeScript
Hard
8 min

What are discriminated unions in TypeScript and how do you enforce exhaustive handling?

Tagged unions that make impossible states unrepresentable, checked with never.

Quiz · TypeScript
Medium
7 min

What are distributive conditional types in TypeScript?

How conditional types map over unions, how to disable it, and the never trap.

Quiz · TypeScript
Hard
7 min

Should you use enums or union literal types in TypeScript?

Runtime enums vs erasable unions, as const objects, and modern toolchain constraints.

Quiz · TypeScript
Medium
6 min

What are excess property checks in TypeScript and when do they apply?

Why fresh object literals reject unknown keys, and when the check doesn't fire.

Quiz · TypeScript
Medium
6 min

What are function overloads in TypeScript and when should you use them?

Multiple call signatures with one hidden implementation, and the alternatives.

Quiz · TypeScript
Medium
6 min

How do you write generic React components in TypeScript?

Type parameters that connect props, tsx syntax quirks, and wrappers that lose generics.

Quiz · TypeScript
Hard
8 min

Explain generics and generic constraints in TypeScript

Type parameters that preserve relationships, constraints, defaults, const and NoInfer.

Quiz · TypeScript
Medium
8 min

What are index signatures in TypeScript and what are their pitfalls?

Dictionaries vs exhaustive Records, noUncheckedIndexedAccess, and when to use Map.

Quiz · TypeScript
Medium
6 min

What is the difference between an interface and a type alias in TypeScript?

Declaration merging and extends vs unions, tuples and type-level computation.

Quiz · TypeScript
Easy
6 min

Explain `keyof`, `typeof` and indexed access types in TypeScript

Deriving key unions, value types and property types from existing code.

Quiz · TypeScript
Medium
6 min

What are mapped types in TypeScript and how does key remapping work?

Iterating keys to build types, modifiers, and as-based renaming and filtering.

Quiz · TypeScript
Medium
7 min

What is module augmentation in TypeScript and when would you use it?

Extending library and global types with declare module and declare global.

Quiz · TypeScript
Medium
6 min

How do you model immutability in TypeScript with `readonly`?

readonly modifiers, Readonly, readonly arrays and as const, and their limits.

Quiz · TypeScript
Medium
6 min

How do you write recursive types in TypeScript, and what are their limits?

Trees, JSON and deep utilities, tail recursion, and compiler performance.

Quiz · TypeScript
Hard
7 min

What does the `satisfies` operator do in TypeScript and how is it different from a type annotation or `as`?

Validate against a type while keeping precise inference.

Quiz · TypeScript
Medium
6 min

What does `strict` mode enable in TypeScript, and which extra flags are worth turning on?

The strict family, noUncheckedIndexedAccess, exactOptionalPropertyTypes and migration strategy.

Quiz · TypeScript
Medium
7 min

What is structural typing in TypeScript and what are its implications?

Compatibility by shape, excess property checks, and when you need nominal types.

Quiz · TypeScript
Easy
6 min

What are template literal types in TypeScript and what are they useful for?

Building and parsing string literal types for handlers, routes and typed paths.

Quiz · TypeScript
Hard
7 min

What are tuple types in TypeScript, including variadic and labeled tuples?

Fixed-position arrays, optional, rest and labeled elements, and variadic tuple types.

Quiz · TypeScript
Medium
6 min

What is the difference between a type assertion and a type annotation in TypeScript?

Checking vs overriding the compiler, non-null assertions, and safer alternatives.

Quiz · TypeScript
Easy
6 min

How does type narrowing work in TypeScript, and how do you write type guards?

Control-flow narrowing, user-defined and inferred type predicates, and assertion functions.

Quiz · TypeScript
Medium
7 min

What are type-only imports in TypeScript and what does `verbatimModuleSyntax` do?

Why per-file transpilers need explicit type imports, and the modern tsconfig setup.

Quiz · TypeScript
Medium
6 min

Do TypeScript types exist at runtime? How do you validate external data?

Type erasure, trust boundaries, schema validation and type stripping.

Quiz · TypeScript
Medium
7 min

How do you type event handlers in React with TypeScript?

Synthetic event types, handler aliases, target vs currentTarget, and DOM listener types.

Quiz · TypeScript
Easy
6 min

How do you type React component props in TypeScript?

Props types, ReactNode children, native element props, exclusive variants and React.FC.

Quiz · TypeScript
Easy
7 min

How do you type refs in React with TypeScript, and what changed in React 19?

DOM refs, mutable refs, ref as a prop, imperative handles and callback ref cleanups.

Quiz · TypeScript
Medium
7 min

How do you type `useReducer` state and actions in TypeScript?

Discriminated-union actions, exhaustive reducers and typed dispatch.

Quiz · TypeScript
Medium
7 min

What are `using` declarations (explicit resource management) in TypeScript?

Scope-bound cleanup with Symbol.dispose, await using and DisposableStack.

Quiz · TypeScript
Medium
6 min

Which built-in TypeScript utility types do you use most, and how do they work?

Partial, Pick, Omit, Record, ReturnType, Awaited and friends, plus their pitfalls.

Quiz · TypeScript
Easy
7 min

Explain covariance, contravariance and invariance in TypeScript

How generic and function types relate under subtyping, strictFunctionTypes and in/out annotations.

Quiz · TypeScript
Hard
9 min

Explain the difference between unit testing, integration testing, and end-to-end testing

Scope, speed, confidence and cost of each level, with front-end examples.

Quiz · JavaScript
Medium
6 min

What does the dependency array of `useEffect` affect?

When effects re-synchronize, Object.is comparison, and stale closures.

Quiz · React
Medium
7 min

What is the difference between `useEffect` and `useLayoutEffect` in React?

Effect timing relative to paint, and when blocking paint is worth it.

Quiz · React
Medium
7 min

How does the View Transitions API work for same-document and cross-document navigations?

startViewTransition, view-transition-name, pseudo-element tree, @view-transition for MPAs, support and pitfalls.

Quiz · CSS
Hard
9 min

Explain the different ways the `this` keyword can be bound

Default, implicit, explicit and new binding, arrow functions, and the precedence between them.

Quiz · JavaScript
Medium
6 min

What are the various ways to create objects in JavaScript?

Object literals, constructors, classes, Object.create, factories and structuredClone compared.

Quiz · JavaScript
Easy
5 min

What are the different ways to make an API call in JavaScript?

fetch, XHR, sendBeacon, WebSocket, SSE and data-fetching libraries, and when to use each.

Quiz · Web & Browser
Easy
6 min

How do you load web fonts without hurting LCP and CLS?

font-display, preloading, subsetting, self-hosting, variable fonts and metric-matched fallbacks.

Quiz · Performance
Medium
8 min

Explain the concept of the WebSocket API

Persistent full-duplex connections: handshake, client API, reconnection and auth concerns.

Quiz · Web & Browser
Medium
7 min

WebSockets vs Server-Sent Events vs long polling: how do you choose a real-time transport?

Directionality, infrastructure, reconnection, scaling and HTTP/2 implications for each real-time option.

Quiz · Web & Browser
Medium
9 min

What advantage is there for using the arrow syntax for a method in a constructor?

The main advantage of using an arrow function as a method inside a constructor is that the value of this gets set at the time of the function creation and can't

Quiz · JavaScript
Medium
3 min

What are data- attributes good for?

Before JavaScript frameworks became popular, front end developers used data- attributes to store extra data within the DOM itself, without other hacks such as n

Quiz · HTML
Medium
3 min

What are empty elements in HTML?

Empty elements in HTML are elements that do not contain any content between their opening and closing tags. Instead, they are self-closing tags, meaning they ha

Quiz · HTML
Medium
3 min

What are JavaScript polyfills for?

Filling missing APIs in older environments, how polyfills differ from transpilation, and their costs.

Quiz · JavaScript
Hard
6 min

What are Promises and how do they work?

Promise objects, chaining, error propagation, microtask scheduling and Promise.withResolvers.

Quiz · JavaScript
Easy
7 min

What are proxies in JavaScript used for?

Intercepting object operations with traps and Reflect: validation, reactivity, logging and their limits.

Quiz · JavaScript
Hard
8 min

What are server-sent events?

One-way streaming over HTTP with EventSource: format, reconnection, limits and alternatives.

Quiz · JavaScript
Hard
7 min

What are some of the advantages/disadvantages of writing JavaScript code in a language that compiles to JavaScript?

Some examples of languages that compile to JavaScript include CoffeeScript, Elm, ClojureScript, PureScript, and TypeScript.

Quiz · JavaScript
Medium
3 min

What are some of the "gotchas" for writing efficient CSS?

Firstly, understand that browsers match selectors from rightmost (key selector) to left. Browsers filter out elements in the DOM according to the key selector a

Quiz · CSS
Medium
3 min

What are `Symbol`s used for in JavaScript?

Unique property keys, the global registry, and well-known symbols that hook into language behaviour.

Quiz · JavaScript
Medium
6 min

What are the advantages and disadvantages of using Ajax?

- Better interactivity. New content from the server can be changed dynamically without the need to reload the entire page.

Quiz · JavaScript
Medium
3 min

What are the advantages/disadvantages of using CSS preprocessors?

- CSS is made more maintainable.

Quiz · CSS
Medium
3 min

What are the benefits of using spread syntax and how is it different from rest syntax?

ES6's spread syntax is very useful when coding in a functional paradigm as we can easily create copies of arrays or objects without resorting to Object.create,

Quiz · JavaScript
Medium
3 min

What are the differences between ES6 class and ES5 function constructors?

Let's first look at an example of each:

Quiz · JavaScript
Medium
3 min

What are the differences between variables created using let, var or const?

Variables declared using the var keyword are scoped to the function in which they are created, or if created outside of any function, to the global object. let

Quiz · JavaScript
Medium
3 min

What are the different ways to visually hide content (and make it available only for screen readers)?

These techniques are related to accessibility (a11y).

Quiz · CSS
Medium
3 min

What are the pros and cons of using Promises instead of callbacks?

- Avoid callback hell which can be unreadable.

Quiz · JavaScript
Medium
3 min

What are the various clearing techniques and which is appropriate for what context?

- Empty div method - <div style="clear:both;"</div.

Quiz · CSS
Medium
3 min

What are workers in JavaScript used for?

Dedicated, shared and service workers: off-main-thread work, messaging, transferables and limits.

Quiz · JavaScript
Hard
7 min

What do you think of AMD vs CommonJS?

Both are ways to implement a module system, which was not natively present in JavaScript until ES2015 came along. CommonJS is synchronous while AMD (Asynchronou

Quiz · JavaScript
Medium
3 min

What does a DOCTYPE do?

DOCTYPE is an abbreviation for Document Type. A DOCTYPE is always associated to a DTD - for Document Type Definition.

Quiz · HTML
Medium
3 min

What does * { box-sizing: border-box; } do? What are its advantages?

- By default, elements have box-sizing: content-box applied, and only the content size is being accounted for.

Quiz · CSS
Medium
3 min

What existing CSS frameworks have you used locally, or in production? How would you change/improve them?

- Bootstrap - Slow release cycle. Bootstrap 4 has been in alpha for almost 2 years. Add a spinner button component, as it is widely used.

Quiz · CSS
Medium
3 min

Explain what happens when the `useState` setter function is called in React

Enqueue, schedule, batch, render, reconcile, commit, and the state snapshot.

Quiz · React
Medium
7 min

What happens, end to end, when you type a URL into the browser and press Enter?

From URL parsing, HSTS and DNS through TLS, HTTP/2 or HTTP/3, caching, parsing and rendering.

Quiz · Web & Browser
Medium
12 min

What is a closure, and how/why would you use one?

A closure is the combination of a function and the lexical environment within which that function was declared. The word "lexical" refers to the fact that lexic

Quiz · JavaScript
Medium
3 min

What is CSS selector specificity and how does it work?

The browser determines what styles to show on an element depending on the specificity of CSS rules. We assume that the browser has already determined the rules

Quiz · CSS
Medium
3 min

What is JSX and how does it work?

How JSX compiles to element-creating calls and the rules that follow.

Quiz · React
Easy
5 min

What is progressive rendering?

Progressive rendering is the name given to techniques used to improve the performance of a webpage (in particular, improve perceived load time) to render conten

Quiz · HTML
Medium
3 min

What is the use of `Promise.all()`

Running independent async work in parallel, fail-fast semantics and concurrency limits.

Quiz · JavaScript
Easy
5 min

What does re-rendering mean in React?

Render vs commit, what triggers re-renders, and when they become a problem.

Quiz · React
Easy
6 min

What is React? Describe the benefits of React

What React is, why teams choose it, and its honest trade-offs.

Quiz · React
Easy
5 min

What is the CSS display property and can you give a few examples of its use?

- none, block, inline, inline-block, flex, grid, table, table-row, table-cell, list-item.

Quiz · CSS
Medium
3 min

What is the definition of a higher-order function?

A higher-order function is any function that takes one or more functions as arguments, which it uses to operate on some data, and/or returns a function as a res

Quiz · JavaScript
Medium
3 min

What is the difference between == and ===?

== is the abstract equality operator while === is the strict equality operator. The == operator will compare for equality after doing any necessary type convers

Quiz · JavaScript
Medium
3 min

What is the difference between canvas and SVG?

Canvas is raster-based, working with pixels, while SVG is vector-based, employing mathematical descriptions of shapes. Canvas employs imperative drawing, where

Quiz · HTML
Medium
3 min

What is the DOM and how is it structured?

The live tree of nodes the browser builds from HTML, node types, and how it relates to rendering.

Quiz · JavaScript
Easy
5 min

What is the extent of your experience with Promises and/or their polyfills?

Possess working knowledge of it. A promise is an object that may produce a single value sometime in the future: either a resolved value or a reason that it's no

Quiz · JavaScript
Medium
3 min

What is "use strict";? What are the advantages and disadvantages to using it?

'use strict' is a statement used to enable strict mode to entire scripts or individual functions. Strict mode is a way to opt into a restricted variant of JavaS

Quiz · JavaScript
Medium
3 min

What is virtual DOM in React?

An in-memory description of the UI that React diffs to update the real DOM.

Quiz · React
Easy
5 min

What kind of things must you be wary of when designing or developing for multilingual sites?

- Use lang attribute in your HTML.

Quiz · HTML
Medium
3 min

What language constructions do you use for iterating over object properties and array items?

- for-in loops - for (var property in obj) { console.log(property); }. However, this will also iterate through its inherited properties, and you will add an obj

Quiz · JavaScript
Medium
4 min

What's a typical use case for anonymous functions?

They can be used in IIFEs to encapsulate some code within a local scope so that variables declared in it do not leak to the global scope.

Quiz · JavaScript
Medium
3 min

What's the difference between a relative, fixed, absolute and statically positioned element?

A positioned element is an element whose computed position property is either relative, absolute, fixed or sticky.

Quiz · CSS
Medium
3 min

What's the difference between a variable that is: null, undefined or undeclared? How would you go about checking for any of these states?

Undeclared variables are created when you assign a value to an identifier that is not previously created using var, let or const. Undeclared variables will be d

Quiz · JavaScript
Medium
3 min

What's the difference between an "attribute" and a "property"?

Attributes are defined on the HTML markup but properties are defined on the DOM. To illustrate the difference, imagine we have this text field in our HTML: <inp

Quiz · JavaScript
Medium
3 min

What's the difference between .call and .apply?

Both .call and .apply are used to invoke functions and the first parameter will be used as the value of this within the function. However, .call takes in comma-

Quiz · JavaScript
Medium
3 min

What's the difference between feature detection, feature inference, and using the UA string?

Feature detection involves working out whether a browser supports a certain block of code, and running different code depending on whether it does (or doesn't),

Quiz · JavaScript
Medium
3 min

What's the difference between host objects and native objects?

Native objects are objects that are part of the JavaScript language defined by the ECMAScript specification, such as String, Math, RegExp, Object, Function, etc

Quiz · JavaScript
Medium
3 min

What's the difference between inline and inline-block?

I shall throw in a comparison with block for good measure.

Quiz · CSS
Medium
3 min

What's the difference between "resetting" and "normalizing" CSS? Which would you choose, and why?

- Resetting - Resetting is meant to strip all default browser styling on elements. For e.g. margins, paddings, font-sizes of all elements are reset to be the sa

Quiz · CSS
Medium
3 min

What tools and techniques do you use for debugging JavaScript code?

- Good old console.log debugging

Quiz · JavaScript
Medium
3 min

When would you use document.write()?

document.write() writes a string of text to a document stream opened by document.open(). When document.write() is executed after the page has loaded, it will ca

Quiz · JavaScript
Medium
3 min

Where should a browser app store JWTs or session tokens: localStorage, memory or cookies?

XSS vs CSRF exposure, HttpOnly cookies, in-memory access tokens with refresh rotation, and the BFF pattern.

Quiz · Security
Hard
10 min

Why is extending built-in JavaScript objects not a good idea?

Extending a built-in/native JavaScript object means adding properties/functions to its prototype. While this may seem like a good idea at first, it is dangerous

Quiz · JavaScript
Medium
3 min

Why is it called a Ternary expression, what does the word "Ternary" indicate?

"Ternary" indicates three, and a ternary expression accepts three operands, the test condition, the "then" expression and the "else" expression. Ternary express

Quiz · JavaScript
Medium
3 min

Why is it generally a good idea to position CSS <link>s between <head></head> and JS <script>s just before </body>? Do you know any exceptions?

Putting <links in the <head is part of proper specification in building an optimized website. When a page first loads, HTML and CSS are being parsed simultaneou

Quiz · HTML
Medium
4 min

Why is it, in general, a good idea to leave the global scope of a website as-is and never touch it?

Every script has access to the global scope, and if everyone uses the global namespace to define their variables, collisions will likely occur. Use the module p

Quiz · JavaScript
Medium
3 min

Why might you want to create static class members?

Static class members (properties/methods) are not tied to a specific instance of a class and have the same value regardless of which instance is referring to it

Quiz · JavaScript
Medium
3 min

Why does React recommend against mutating state?

Reference equality, memoization, snapshots and concurrent rendering all assume immutability.

Quiz · React
Easy
6 min

Why would you use something like the load event? Does this event have disadvantages? Do you know any alternatives, and why would you use those?

The load event fires at the end of the document loading process. At this point, all of the objects in the document are in the DOM, and all the images, scripts,

Quiz · JavaScript
Medium
3 min

Why you would use a srcset attribute in an image tag? Explain the process the browser uses when evaluating the content of this attribute.

You would use the srcset attribute when you want to serve different images to users depending on their device display width - serve higher quality images to dev

Quiz · HTML
Medium
3 min

How do you use the window.history API?

pushState, replaceState, popstate and the building blocks of client-side routing.

Quiz · Web & Browser
Easy
6 min

What is the difference between the Window object and the Document object?

The global browsing-context object versus the DOM tree of the loaded page.

Quiz · Web & Browser
Medium
5 min

How do you write unit tests for JavaScript code?

Arrange-act-assert, testing behaviour not implementation, isolation and edge cases.

Quiz · JavaScript
Medium
6 min

What are the differences between `XMLHttpRequest` and `fetch()` in JavaScript and browsers?

Promise-based fetch versus event-based XHR: errors, cancellation, streaming, progress and cookies.

Quiz · JavaScript
Easy
6 min

Explain stored, reflected and DOM-based XSS. Does using React make you safe?

The three XSS classes, what JSX escaping does and doesn't cover, and defence in depth.

Quiz · Security
Medium
9 min