The DOM: interview questions

Walking and searching the element tree, events and delegation, and building small DOM utilities. 26 questions from the Front End Interview Handbook. 8 have our own answer, built up from basic to advanced, with code that is proved by tests (how answers are checked).

  1. DOM APIs: document.getElementByClassName(), document.getElementByTagName()The DOM · basicJavaScript codingcheckednot tried
  2. Generate table of contents/outline from a HTML page (similar to Google Docs autogenerated outline).The DOM · advancedJavaScript codingcheckednot tried
  3. React-like VDOM but instead of creating DOM nodes, output an HTML string given an input object with type and attributes.React, The DOM · reported at ByteDance/TikTokJavaScript codingcheckednot tried
  4. Implement getByClassName() and getByClassnameHierarchy()The DOM · reported at DropboxJavaScript codingcheckednot tried
  5. DFS on HTML nodes.The DOM, Data structures and algorithms · reported at GoogleJavaScript codingcheckednot tried
  6. Write a getElementsByClassName function.The DOM · reported at LinkedInJavaScript codingcheckednot tried
  7. Find the identical DOM node in two identical trees: given a node in one tree, locate the equivalent node in the other tree by reference. Efficient solution: walk up via parentNode, record the path, then replay the path in the other tree (avoids touching unrelated nodes vs. DFS/BFS).The DOM · reported at MetaJavaScript codingcheckednot tried
  8. Read HTML form data and construct a JSON object.The DOM, HTML · reported at RedditJavaScript codingcheckednot tried
  9. Explain event delegationThe DOMQuizhandbooknot tried
  10. Describe event bubbling.The DOMQuizhandbooknot tried
  11. Explain how a browser determines what elements match a CSS selector.The DOM, CSS and layoutQuizhandbooknot tried
  12. Describe pseudo-elements and discuss what they are used for.CSS and layout, The DOMQuizhandbooknot tried
  13. What's the difference between a relative, fixed, absolute and statically positioned element?The DOM, CSS and layoutQuizhandbooknot tried
  14. What are empty elements in HTML?The DOM, HTMLQuizhandbooknot tried
  15. Implement a function getElementsByStyle(property, value) that returns all elements in the DOM that match that style.The DOM · reported at AmazonCodingno answer yetnot tried
  16. Fetch todos from an API and render 20 at a time. The dummy API takes params to control how many you get. Use fetch with no helper libraries; brush up on creating, appending, and removing DOM elements.The DOM, UI components · reported at AtlassianUser interface codingno answer yetnot tried
  17. "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
  18. Build a chat web app (Discord-style). Some candidates are asked the full-stack version (React + Node.js with WebSockets); front-end-only candidates have been asked a UI variant of the same.The DOM, Data structures and algorithms · reported at DiscordUser interface codingno answer yetnot tried
  19. Prepare to debug and refactor an existing JavaScript/Node.js application, as outlined to an applicant before their round. The stated concerns were reliability, security, and maintainability.The DOM, Security · reported at eBayJavaScript codingno answer yetnot tried
  20. Design a webpage which can auto load new posts when you reach the bottom of the page by using JavaScript. You may use AJAX and JavaScript event listeners.The DOM, Frontend system design · reported at GoogleUser interface codingno answer yetnot tried
  21. Difference between event bubbling and capturing?The DOM · reported at LinkedInQuizno answer yetnot tried
  22. What is event delegation?The DOM · reported at LinkedInQuizno answer yetnot tried
  23. 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
  24. What is DOM?The DOM · reported at MicrosoftQuizno answer yetnot tried
  25. Explain why the React implementation works, including state updates, DOM behavior, and CSS text rendering.The DOM, React · reported at OpenAICodingno answer yetnot tried
  26. Tech screen: vanilla JavaScript bug-fix. You are given a working but buggy file with several classes (the example reported was a shopping cart with review comments and a 5-star rating widget). One by one the interviewer tells you what the bug is (e.g. "the 5-star widget lets you review more than once") and you fix it. Bugs cover state manipulation, array handling, DOM updates. Open book — you can search online. At the end, they ask for an overall code review of the file: how you would have implemented the whole thing differently, what you'd change about data, state, and performance.Arrays and objects, The DOM · reported at SquarespaceUser interface codingno answer yetnot tried