Important Question And Answer

1: What is DOM and what is the purpose of DOM?

DOM Means The Document Object Model.It is a programming interface for web documents. It Is RePresents The pages So That progrram can change the document structure, style, and content. The DOM represents the document as nodes and objects; that way, programming languages can interact with the page.

2: How will you select HTML elements using DOM? Name the DOM methods.

There Are 5 Ways in which you can select elements in a DOM using selectors.

1:getElementsByTagName()
2:getElementsByClassName()
3:getElementById()
4:querySelector()
5:querySelectorAll()

3: What is event bubble?

Event bubbling is a type of DOM event propagation where the event first triggers on the innermost target element, and then successively triggers on the ancestors of the target element in the same nesting hierarchy till it reaches the outermost DOM element or document object.

4: What is a callback function and why will you use it?

A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.

function greeting(name) {
                                alert(`Hello, ${name}`);
                              }
                              
                              function processUserInput(callback) {
                                const name = prompt("Please enter your name.");
                                callback(name);
                              }
                              
                              processUserInput(greeting);