Async, promises and timers: interview questions
Promises from scratch, running work in sequence or with a limit, debounce and throttle, queues, retries and timers. 43 questions from the Front End Interview Handbook. 20 have our own answer, built up from basic to advanced, with code that is proved by tests (how answers are checked).
- Implement Promise/Promise-related APIs:
Promise,Promise.all,Promise.anyAsync, promises and timers · basic · has a lessonJavaScript codingcheckednot tried - Implement Lodash functions:
debounce(),throttle(),cloneDeep(),groupBy()Async, promises and timers, Functions, this and closures · basicJavaScript codingcheckednot tried - Lodash's
chunk()/map()with follow up ofmapAsync(Promise.all) thenmapWithChunksAsyncArrays and objects, Async, promises and timers · basicJavaScript codingcheckednot tried - Given an API
getAllLinks(url)that returns all the links on a page, write a function that returns all descendant links (child URLs of child URLs, etc.). Handle edge cases: circular dependencies,getAllLinksreturning a promise, async efficiency, and time complexity.Async, promises and timers, Data structures and algorithms · reported at AdobeJavaScript codingcheckednot tried - Implement a custom React hook that uses
setInterval. Common gotcha: the interval double-fires unless you keep the callback in auseRefinstead ofuseState.React, Async, promises and timers · reported at AdobeJavaScript codingcheckednot tried - Write a simple promise.Async, promises and timers · reported at AirbnbJavaScript codingcheckednot tried
- How can you execute an array of promises in sequence?Async, promises and timers · reported at AppleJavaScript codingcheckednot tried
- Know
Promise.anyfrom memory.Async, promises and timers · reported at AtlassianJavaScript codingcheckednot tried - Implement
Promise.all.Async, promises and timers · reported at ByteDance/TikTok, LyftJavaScript codingcheckednot tried - Implement concurrency-limited async mapping. One earlier interview required a particular approach, so clarify scheduling constraints before coding.Async, promises and timers · reported at ByteDance/TikTokJavaScript codingcheckednot tried
- Implement a
composemiddleware function so that async middlewares like Koa-stylef1,f2,f3(each callingnext()) execute in the correct nested order.Functions, this and closures, Async, promises and timers · reported at ByteDance/TikTokJavaScript codingcheckednot tried - Fix a buggy
fetchhelper: the provided function may look right but doesn'treturnthe promise fromfetch(...). You're expected to spot it.Async, promises and timers, Network and APIs · reported at DoorDashJavaScript codingcheckednot tried - How do you make a function that takes a callback function
fnand returns a function that callsfnon a timeout?Async, promises and timers, Functions, this and closures · reported at GoogleJavaScript codingcheckednot tried - Implement
throttle, for example allowing an input function to run at most once every 50 milliseconds.Async, promises and timers, Functions, this and closures · reported at GoogleJavaScript codingcheckednot tried - Implement a
Decryptionclass — focuses on managing async operations and a callback queue. The provideddecryptEncrypt(key, payload, callback)generates a new key per call; your class must enqueue callbacks and process them in order as decryption completes. (The name is misleading — it's an async-operations question, not a security question.)Async, promises and timers · reported at MetaJavaScript codingcheckednot tried - Implement a number/character pad like old flip phones — buttons where
2 = abc,3 = def, etc. Pressing the same key cycles through letters within a short time window; after a delay, the next press appends. e.g. press 2 →a, press 2 again →b, wait 1s and press 2 →ba, press 6 →bam.Async, promises and timers, Strings and parsing · reported at MicrosoftJavaScript codingcheckednot tried - Implement a hand-rolled
throttle; one screen prohibited library imports.Async, promises and timers, Functions, this and closures · reported at RipplingJavaScript codingcheckednot tried - Implement an async process queue with concurrency control. Follow-up: handle async-task failures by accepting an error callback handler.Async, promises and timers · reported at UberJavaScript codingcheckednot tried
- Build a utility in JS that sends data in batches with a timeout: as soon as the batch size is reached, send immediately and restart the timer; if the timer fires before the batch is filled, send what's there and restart.Async, promises and timers · reported at UberJavaScript codingcheckednot tried
- Extend an async batcher with retry behavior and operations such as
push,flush, andclear.Async, promises and timers · reported at UberJavaScript codingcheckednot tried - What is the extent of your experience with Promises and/or their polyfills?Async, promises and timers, Functions, this and closuresQuizhandbooknot tried
- What are the pros and cons of using Promises instead of callbacks?Async, promises and timersQuizhandbooknot tried
- Explain the difference between synchronous and asynchronous functions.Async, promises and timersQuizhandbooknot tried
- What is event loop? What is the difference between call stack and task queue?Async, promises and timers, Functions, this and closures · has a lessonQuizhandbooknot tried
- Describe the difference between
<script>,<script async>and<script defer>.HTML, Async, promises and timers · has a lessonQuizhandbooknot tried - Build an image carousel where each slide has a different duration and the carousel stops on the last image. Follow-up: show a countdown on each slide, auto-advance to the next image at 0, and stop at the end. Keep timer state and cleanup explicit as you add the countdown.Async, promises and timers, UI components · reported at AirbnbUser interface codingno answer yetnot tried
- Auto-suggest dropdown with debounce — implement the HTML/CSS for an input plus a few search-result items, then add debounced fetching as a follow-up.Async, promises and timers, UI components · reported at AmazonCodingno answer yetnot tried
- Design an SDK in JavaScript implementing throttling and retry strategies. Focus on defining contracts that consumers will adhere to — feels like a mix of system design and coding.Async, promises and timers, Frontend system design · reported at AmazonCodingno answer yetnot tried
- Know async generators,
await,yield,async for awaitloop, andPromise.resolve.Async, promises and timers · reported at AtlassianJavaScript codingno answer yetnot tried - JavaScript quiz: given a list of Promises with console statements, determine the order they will print.Async, promises and timers · reported at ByteDance/TikTok · has a lessonJavaScript codingno answer yetnot tried
- Standard promise-based JS question (the kind common in most practice sets).Async, promises and timers · reported at CanvaJavaScript codingno answer yetnot tried
- "Language proficiency" round: build an in-memory comment service in TypeScript. Prep covers DOM mutations, event handling, async, and core JavaScript fundamentals. They send a starter pack of HTML/CSS/JS files ahead of time — set up your TypeScript environment before the interview.Async, promises and timers, The DOM · reported at CanvaJavaScript codingno answer yetnot tried
- Extend a server with asynchronous endpoints that aggregate several data sources. Follow-ups can involve validation, request logging, notifications, and streamed updates.Async, promises and timers · reported at eBayJavaScript codingno answer yetnot tried
- Difference between promise and callback?Async, promises and timers · reported at LinkedInQuizno answer yetnot tried
- Difference between callback and closure in JavaScript?Async, promises and timers, Functions, this and closures · reported at LinkedInQuizno answer yetnot tried
- Sticky ads on scroll: implement an ad element that follows the user as they scroll. Throttle is preferred over debounce here because the ad must reposition during the scroll, not after it ends.Async, promises and timers, The DOM · reported at MetaUser interface codingno answer yetnot tried
- Design an SDK in JavaScript implementing features like throttling and retry strategies. Focus on defining contracts that consumers will adhere to.Async, promises and timers, Frontend system design · reported at MicrosoftJavaScript codingno answer yetnot tried
- Discuss the component tree, schemas, APIs, real-time updates, and concurrent edits.Async, promises and timers, Data structures and algorithms · reported at OpenAISystem designno answer yetnot tried
- Use React with
setIntervalandsetTimeoutto animate or visualize data.Async, promises and timers, Data structures and algorithms · reported at RedditUser interface codingno answer yetnot tried - Build a job board: fetch and display posts, add a "load more" button, then layer on infinite scroll using
IntersectionObserver, throttling on scroll, and deduping of fetched items.Async, promises and timers, Arrays and objects · reported at RipplingUser interface codingno answer yetnot tried - Implement a custom Promise class or process records from logs.Async, promises and timers · reported at RobloxCodingno answer yetnot tried
- What is the event loop?Async, promises and timers · reported at Salesforce · has a lessonQuizno answer yetnot tried
- Create a button that when clicked, adds a progress bar onto the page. The progress bar would then fill up in a given amount of time (think 3 to 5 seconds). If you get past the first part, you will be asked to do throttling how many progress bars can be running at once. For example, if the limit is 3 progress bars, and the user clicks on the button 4 times, the fourth progress bar only starts after the very first one finishes. SourceAsync, promises and timers, Data structures and algorithms · reported at UberUser interface codingno answer yetnot tried