Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 4 MCQs DOM Manipulation and Modern Tooling

INT219 — Front End Web Developer 60 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 60 answered 0 right 0 wrong , 60 left

  1. Question 1 of 60 Document Object Model (DOM) structure Easy

    What does "DOM" stand for?

  2. Question 2 of 60 Document Object Model (DOM) structure Easy

    How does the DOM represent an HTML document?

  3. Question 3 of 60 Document Object Model (DOM) structure Easy

    In the DOM tree, what is the topmost node that serves as the entry point to the page's content?

  4. Question 4 of 60 DOM traversal and manipulation Easy

    Which JavaScript method is specifically designed to select a single HTML element by its unique id?

  5. Question 5 of 60 DOM traversal and manipulation Easy

    Which method should you use to select the first element that matches a specific CSS selector, like div.my-class?

  6. Question 6 of 60 DOM traversal and manipulation Easy

    To change the text inside a <p> tag while ensuring no HTML is rendered, which property is the safest to use?

  7. Question 7 of 60 Dynamic styling and content updates Easy

    How can you change the CSS color property of an element to red using JavaScript?

  8. Question 8 of 60 Dynamic styling and content updates Easy

    What does the element.classList.add('new-class') method do?

  9. Question 9 of 60 Event propagation and delegation Easy

    What is an "event" in the context of the DOM?

  10. Question 10 of 60 Event propagation and delegation Easy

    What is the default direction of event propagation in modern browsers, where an event travels from the target element up to its ancestors?

  11. Question 11 of 60 Event propagation and delegation Easy

    Which modern JavaScript method is used to attach an event handler (like a function) to an element?

  12. Question 12 of 60 Debugging using browser developer tools Easy

    Which browser developer tool panel is primarily used for logging messages and errors from your JavaScript code?

  13. Question 13 of 60 Debugging using browser developer tools Easy

    In the developer tools, which panel allows you to inspect and edit the live HTML and CSS of a webpage?

  14. Question 14 of 60 Debugging using browser developer tools Easy

    What is the primary purpose of the console.log() function?

  15. Question 15 of 60 Module bundling concepts using modern build tools Easy

    What is the main purpose of a JavaScript module bundler like Webpack or Vite?

  16. Question 16 of 60 Module bundling concepts using modern build tools Easy

    Which of the following is a popular JavaScript module bundler?

  17. Question 17 of 60 Code linting and formatting practices Easy

    What is the main function of a code linter like ESLint?

  18. Question 18 of 60 Code linting and formatting practices Easy

    What is the primary role of a code formatter like Prettier?

  19. Question 19 of 60 DOM traversal and manipulation Easy

    Which JavaScript method is used to create a new HTML element from scratch?

  20. Question 20 of 60 Dynamic styling and content updates Easy

    To completely replace an element's content with new HTML content, which property is most suitable?

  21. Question 21 of 60 DOM traversal and manipulation Medium

    Consider the following HTML snippet:

    HTML
    <div id="parent">
      <!-- Some comment -->
      <p>First paragraph</p>
      <span>A span</span>
    </div>



    What is the difference in output between document.getElementById('parent').childNodes.length and document.getElementById('parent').children.length?

  22. Question 22 of 60 Event propagation and delegation Medium

    Given the HTML below, if a user clicks on the <p> element, in what order will the alerts fire during the bubbling phase?

    HTML
    <div id="grandparent">
      <div id="parent">
        <p id="child">Click me!</p>
      </div>
    </div>
    
    <script>
      document.getElementById('grandparent').addEventListener('click', () => alert('grandparent'));
      document.getElementById('parent').addEventListener('click', () => alert('parent'));
      document.getElementById('child').addEventListener('click', () => alert('child'));
    </script>

  23. Question 23 of 60 Module bundling concepts using modern build tools Medium

    In the context of a module bundler like Webpack or Vite, what is the primary purpose of 'tree shaking'?

  24. Question 24 of 60 Code linting and formatting practices Medium

    What is the key difference between a code linter (like ESLint) and a code formatter (like Prettier)?

  25. Question 25 of 60 Dynamic styling and content updates Medium

    You need to apply ten different CSS style changes to a single DOM element in response to a user action. Which of the following approaches is generally most performant?

  26. Question 26 of 60 Debugging using browser developer tools Medium

    You notice a JavaScript function is being called with an incorrect value, but only after it has been executed hundreds of times in a loop. Which debugging feature would be most efficient for pausing execution only when the problematic value appears?

  27. Question 27 of 60 Event propagation and delegation Medium

    Why is event delegation a recommended pattern for handling events on a large list of items, especially if items are added or removed dynamically?

  28. Question 28 of 60 DOM traversal and manipulation Medium

    What is the primary advantage of using document.createDocumentFragment() when appending multiple elements to the DOM?

  29. Question 29 of 60 Document Object Model (DOM) structure Medium

    Which of the following statements accurately describes the relationship between the DOM and an HTML document?

  30. Question 30 of 60 Dynamic styling and content updates Medium

    What is the key difference between setting an element's textContent versus its innerHTML?

  31. Question 31 of 60 Module bundling concepts using modern build tools Medium

    In a modern front-end build process, what is the typical role of a tool like Babel?

  32. Question 32 of 60 Debugging using browser developer tools Medium

    You have a CSS rule !important that is still being overridden by another style. Where in the Chrome Developer Tools would be the best place to investigate which style is taking precedence and why?

  33. Question 33 of 60 Event propagation and delegation Medium

    What is the effect of calling event.stopPropagation() inside an event listener?

  34. Question 34 of 60 DOM traversal and manipulation Medium

    Given the following JavaScript code, what will the final structure of the <ul> element look like?

    HTML
    <ul id="myList">
      <li id="item1">Apple</li>
      <li id="item2">Banana</li>
    </ul>
    
    <script>
      const list = document.getElementById('myList');
      const item1 = document.getElementById('item1');
      const new_item = document.createElement('li');
      new_item.textContent = 'Cherry';
      list.insertBefore(new_item, item1);
    </script>

  35. Question 35 of 60 Code linting and formatting practices Medium

    A development team wants to ensure that every time a developer commits code, it is automatically checked for both stylistic consistency and potential logical errors (like using a variable before it's defined). Which combination of tools is best suited for this automated workflow?

  36. Question 36 of 60 Document Object Model (DOM) structure Medium

    In the DOM tree, what type of node represents the actual text inside an element like <p>Hello World</p>?

  37. Question 37 of 60 Dynamic styling and content updates Medium

    What is the purpose of the dataset property on an HTML element in JavaScript?

  38. Question 38 of 60 Debugging using browser developer tools Medium

    You are trying to debug a complex layout issue where an element is not sized or positioned as expected. Which feature in browser developer tools would be most helpful for visualizing the element's box model (margin, border, padding, and content)?

  39. Question 39 of 60 Module bundling concepts using modern build tools Medium

    What problem do module bundlers primarily solve in the context of front-end development?

  40. Question 40 of 60 DOM traversal and manipulation Medium

    Consider an element <button id="myBtn">Click</button>. Which JavaScript selector would find the closest ancestor element that has the class container?

  41. Question 41 of 60 Event propagation and delegation Hard

    Consider the following HTML structure and JavaScript code. What is the final output logged to the console when the child div is clicked?

    HTML
    <div id="parent">
      <div id="child">Click Me</div>
    </div>



    JavaScript
    const parent = document.getElementById('parent');
    const child = document.getElementById('child');
    
    parent.addEventListener('click', () => console.log('Parent Bubble'), false);
    parent.addEventListener('click', () => console.log('Parent Capture'), true);
    
    child.addEventListener('click', (e) => {
      console.log('Child Bubble');
      e.stopImmediatePropagation();
    }, false);
    
    child.addEventListener('click', () => console.log('Child Capture'), true);
    child.addEventListener('click', () => console.log('Child Bubble 2'), false);

  42. Question 42 of 60 Module bundling concepts using modern build tools Hard

    In a Webpack configuration, you are trying to implement long-term caching using [contenthash]. You notice that changing a CSS file also changes the content hash of your main JavaScript entry bundle, even though the JS code itself hasn't changed. What is the most likely cause and solution for this behavior?

  43. Question 43 of 60 DOM traversal and manipulation Hard

    You are tasked with improving the performance of a script that adds 1000 <li> elements to a <ul> in the DOM. Which of the following methods is generally the most performant and why?

    Method A: Loop 1000 times, creating an <li> and calling ul.appendChild() in each iteration.
    Method B: Loop 1000 times, creating an <li> and appending it to a DocumentFragment, then appending the fragment to the ul once.
    * Method C: Build a single string of 1000 <li> elements and set ul.innerHTML with this string.

  44. Question 44 of 60 Dynamic styling and content updates Hard

    A script needs to apply several style changes to an element and then read its final dimensions. The code is structured as follows:

    JavaScript
    const element = document.getElementById('my-box');
    element.style.width = '100px';
    element.style.height = '100px';
    element.style.opacity = '0.5';
    
    // Read dimensions
    const rect = element.getBoundingClientRect();
    console.log(rect.width);
    
    element.style.opacity = '1';



    Which statement best describes the performance implications of this code?

  45. Question 45 of 60 Debugging using browser developer tools Hard

    While using the Chrome DevTools Performance profiler, you observe a large, solid purple block labeled 'Layout' in the flame chart, which is causing significant UI jank. What is the most effective initial step to diagnose the root cause of this 'forced synchronous layout'?

  46. Question 46 of 60 Code linting and formatting practices Hard

    Your team uses ESLint and Prettier, but you encounter a conflict: Prettier formats code in a way that violates an ESLint rule (e.g., max-len). What is the standard, recommended practice for resolving such conflicts and ensuring a smooth developer experience?

  47. Question 47 of 60 Document Object Model (DOM) structure Hard

    When an event originating from within a Shadow DOM is dispatched, and it crosses the shadow boundary into the light DOM, what happens to the event.target property as observed by listeners in the light DOM?

  48. Question 48 of 60 Module bundling concepts using modern build tools Hard

    You're using an ES module-based library and have configured Webpack for tree-shaking. However, you notice that a large, unused portion of the library is still included in your final bundle. The library's package.json does NOT have a "sideEffects" field. Which of the following is the most probable cause for the tree-shaking failure?

  49. Question 49 of 60 DOM traversal and manipulation Hard

    What is a key difference between a NodeList returned by document.querySelectorAll() and an HTMLCollection returned by document.getElementsByTagName() in modern browsers?

  50. Question 50 of 60 Event propagation and delegation Hard

    You are implementing event delegation on a complex list where each <li> contains multiple nested elements. You want to trigger a function only when a click originates specifically on a <span> with the class .icon inside any <li>. Which event handler implementation is the most robust and efficient?

    HTML
    <ul id="myList">
      <li>Item 1 <span class="icon">X</span></li>
      <li>Item 2 <button>Action <span class="icon">Y</span></button></li>
    </ul>

  51. Question 51 of 60 Dynamic styling and content updates Hard

    To achieve a smooth, high-performance animation in JavaScript (e.g., moving an element across the screen), why is using requestAnimationFrame(callback) superior to using setInterval(callback, 16) or a recursive setTimeout(callback, 16)?

  52. Question 52 of 60 Debugging using browser developer tools Hard

    You're debugging a complex JavaScript application and suspect a specific function, updateState(), is being called with an invalid argument, but only under very specific, hard-to-reproduce conditions. The function is called thousands of times. What is the most efficient way to pause execution only when updateState(arg) is called where arg.id is null?

  53. Question 53 of 60 Code linting and formatting practices Hard

    What is the primary purpose of the overrides key in an ESLint configuration file (.eslintrc.js) and in what scenario is it most critically used?

  54. Question 54 of 60 Document Object Model (DOM) structure Hard

    Which of these statements accurately describes the relationship between the DOM, CSSOM, and the Render Tree?

  55. Question 55 of 60 Module bundling concepts using modern build tools Hard

    In the context of Webpack, what is the fundamental difference between a loader and a plugin?

  56. Question 56 of 60 DOM traversal and manipulation Hard

    Given the following HTML snippet, what will el.querySelector(':scope > .c') select, where el is the DOM element with the ID a?

    HTML
    <div id="a">
        <div class="c">
            <!-- C1 -->
            <div class="b">
                <div class="c"></div> <!-- C2 -->
            </div>
        </div>
        <div class="b">
            <div class="c"></div> <!-- C3 -->
        </div>
    </div>

  57. Question 57 of 60 Dynamic styling and content updates Hard

    What is the primary difference between setting an element's opacity to 0 and setting its display to none?

  58. Question 58 of 60 Event propagation and delegation Hard

    Under what specific circumstance would you need to use pointer-events: none; in CSS as part of a complex event delegation strategy?

  59. Question 59 of 60 Module bundling concepts using modern build tools Hard

    What is the primary purpose of a 'source map' (.js.map file) generated by a build tool like Webpack, and how does it relate to debugging?

  60. Question 60 of 60 DOM traversal and manipulation Hard

    Consider the following code intended to remove all child nodes from a div with the id container. Why is the first approach problematic, while the second one works correctly?

    JavaScript
    // Approach 1 (Problematic)
    const container1 = document.getElementById('container');
    const children1 = container1.children;
    for (let i = 0; i < children1.length; i++) {
        container1.removeChild(children1[i]);
    }
    
    // Approach 2 (Correct)
    const container2 = document.getElementById('container');
    while (container2.firstChild) {
        container2.removeChild(container2.firstChild);
    }

That's unit 4

Answer a few questions and your score shows up here.