!
Question-1: What are the different ways to select an element in the DOM?
There are multiple ways to select an element in the dom , some of them are getElementById(), getElementsByClassName(), getElementsByTagName(), querySelector(), querySelectorAll().
Question-2: What is the difference between innerHTML, innerText, and textContent ?
The difference between innerHTML, innerText, and textContent is that innerHTML gets/sets HTML inside an element, innerText gets/sets only visible text, and textContent gets/sets all text (including hidden ones) without parsing HTML.
Question-3: What is event delegation in the DOM?
Event delegation is when a single event listener is attached to a parent element instead of multiple child elements and lets events "bubble up" to handle them efficiently.
Question-4: What is event bubbling in the DOM?
Event bubbling in the DOM means that when an event happens on a nested element, it first runs its handler and then "bubbles up" to its parent elements, triggering their handlers too.
Question-5: How do you create, add, and remove elements using JavaScript?
The way of creating an element is with document.createElement(), add it using appendChild() or append(), and remove it with remove().