The Document Object Model (DOM) is a programming interface for HTML and XML documents. It represents the page so that programs can change the document structure, style, and content. The DOM provides a way for programmers to access and manipulate HTML and XML documents, which makes it essential for building dynamic web pages and applications.
Closures are functions that have access to variables in their outer (enclosing) functions, even after the outer function has returned. This is possible because the inner function retains a reference to the variables in the outer function, which are kept alive in memory.
An object is a collection of properties, where each property is a key-value pair. An array is an ordered list of values, where each value is accessed by its index number.
Objects can be created using object literals or using the Object constructor function. For example, an object can be created using an object literal like this:
Synchronous programming is when tasks are executed sequentially, one after the other, in a predictable order.
Asynchronous programming is when tasks are executed concurrently, and the order of execution is not guaranteed.
Async/await is a way to write asynchronous code that looks like synchronous code. It allows developers to write code that waits for a promise to resolve before executing the next line of code.
The == operator compares values for equality, whereas the === operator compares values for equality and type.
Event bubbling is the process by which an event propagates from the innermost element that triggered the event up to the document root, triggering all event handlers along the way.
Event delegation is a technique in which a single event handler is added to a parent element, rather than multiple event handlers being added to multiple child elements.
It can only handle a single function at a time, which means that if multiple onclick attributes are added to the same element, only the last one will be executed.Also, it cannot be removed once it is set.
On the other hand, addEventListener is a method that allows you to attach multiple event listeners to an element.
It can handle multiple functions at the same time and the order in which they are added is preserved. Also, it allows you to remove a specific listener from the element using the removeEventListener method.
It is a text format that is used to represent data in a structured way and is widely used for data exchange between web servers and clients.
It allows web applications to update parts of a web page without refreshing the entire page, providing a smoother and more responsive user experience.
Here’s an example of how to use the XHR object to send an HTTP
GET request to a web server and receive a JSON response:
1.Syntax errors: These occur when the syntax of a program is incorrect and prevent the program from running.
Syntax errors are usually caused by typographical errors, missing brackets, or invalid statements. For example, forgetting to close a bracket or using an incorrect operator can cause a syntax error.
2.Runtime errors: These occur during the execution of a program and can cause it to crash or behave unexpectedly.
Runtime errors are usually caused by invalid data or unexpected conditions, such as dividing a number by zero or trying to access a non-existent object
3.Logical errors: These occur when a program runs without crashing but produces incorrect or unexpected results.
Logical errors are usually caused by errors in the program’s algorithm or logic, such as using the wrong formula for a calculation or not handling a specific condition.
The try block contains the code that might throw an exception, while the catch block handles the exception by executing a set of statements.
Here’s an example:
null is a value that represents the intentional absence of any object value. It is often used to indicate that a variable has no value assigned to it. undefined, on the other hand, is a value that represents an uninitialized variable or a missing property
in an object.
the call stack.