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).

  1. Implement Promise/Promise-related APIs: Promise, Promise.all, Promise.anyAsync, promises and timers · basic · has a lessonJavaScript codingcheckednot tried
  2. Implement Lodash functions: debounce(), throttle(), cloneDeep(), groupBy()Async, promises and timers, Functions, this and closures · basicJavaScript codingcheckednot tried
  3. Lodash's chunk()/map() with follow up of mapAsync(Promise.all) then mapWithChunksAsyncArrays and objects, Async, promises and timers · basicJavaScript codingcheckednot tried
  4. 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, getAllLinks returning a promise, async efficiency, and time complexity.Async, promises and timers, Data structures and algorithms · reported at AdobeJavaScript codingcheckednot tried
  5. Implement a custom React hook that uses setInterval. Common gotcha: the interval double-fires unless you keep the callback in a useRef instead of useState.React, Async, promises and timers · reported at AdobeJavaScript codingcheckednot tried
  6. Write a simple promise.Async, promises and timers · reported at AirbnbJavaScript codingcheckednot tried
  7. How can you execute an array of promises in sequence?Async, promises and timers · reported at AppleJavaScript codingcheckednot tried
  8. Know Promise.any from memory.Async, promises and timers · reported at AtlassianJavaScript codingcheckednot tried
  9. Implement Promise.all.Async, promises and timers · reported at ByteDance/TikTok, LyftJavaScript codingcheckednot tried
  10. 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
  11. Implement a compose middleware function so that async middlewares like Koa-style f1, f2, f3 (each calling next()) execute in the correct nested order.Functions, this and closures, Async, promises and timers · reported at ByteDance/TikTokJavaScript codingcheckednot tried
  12. Fix a buggy fetch helper: the provided function may look right but doesn't return the promise from fetch(...). You're expected to spot it.Async, promises and timers, Network and APIs · reported at DoorDashJavaScript codingcheckednot tried
  13. How do you make a function that takes a callback function fn and returns a function that calls fn on a timeout?Async, promises and timers, Functions, this and closures · reported at GoogleJavaScript codingcheckednot tried
  14. 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
  15. Implement a Decryption class — focuses on managing async operations and a callback queue. The provided decryptEncrypt(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
  16. 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
  17. Implement a hand-rolled throttle; one screen prohibited library imports.Async, promises and timers, Functions, this and closures · reported at RipplingJavaScript codingcheckednot tried
  18. 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
  19. 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
  20. Extend an async batcher with retry behavior and operations such as push, flush, and clear.Async, promises and timers · reported at UberJavaScript codingcheckednot tried
  21. What is the extent of your experience with Promises and/or their polyfills?Async, promises and timers, Functions, this and closuresQuizhandbooknot tried
  22. What are the pros and cons of using Promises instead of callbacks?Async, promises and timersQuizhandbooknot tried
  23. Explain the difference between synchronous and asynchronous functions.Async, promises and timersQuizhandbooknot tried
  24. 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
  25. Describe the difference between <script>, <script async> and <script defer>.HTML, Async, promises and timers · has a lessonQuizhandbooknot tried
  26. 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
  27. 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
  28. 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
  29. Know async generators, await, yield, async for await loop, and Promise.resolve.Async, promises and timers · reported at AtlassianJavaScript codingno answer yetnot tried
  30. 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
  31. Standard promise-based JS question (the kind common in most practice sets).Async, promises and timers · reported at CanvaJavaScript codingno answer yetnot tried
  32. "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
  33. 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
  34. Difference between promise and callback?Async, promises and timers · reported at LinkedInQuizno answer yetnot tried
  35. Difference between callback and closure in JavaScript?Async, promises and timers, Functions, this and closures · reported at LinkedInQuizno answer yetnot tried
  36. 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
  37. 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
  38. 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
  39. Use React with setInterval and setTimeout to animate or visualize data.Async, promises and timers, Data structures and algorithms · reported at RedditUser interface codingno answer yetnot tried
  40. 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
  41. Implement a custom Promise class or process records from logs.Async, promises and timers · reported at RobloxCodingno answer yetnot tried
  42. What is the event loop?Async, promises and timers · reported at Salesforce · has a lessonQuizno answer yetnot tried
  43. 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