In JavaScript, how does the prototype chain relate to object inheritance?
The prototype chain manages asynchronous tasks related to object creation.
It establishes a hierarchy for property and method lookup, enabling objects to inherit from prototypes.
The prototype chain determines the order of function execution within an object.
It's used for event handling and propagation within the DOM.
What is the primary role of the this keyword in JavaScript?
this
It creates a new object instance.
It refers to the current date and time.
It points to the object that the function is a property of, determined at function call time.
It accesses the global scope.
In what scenario would you typically use a callback function?
To create a loop that iterates a specific number of times.
To log data to the console for debugging purposes.
To perform an action after an asynchronous operation completes, like fetching data from an API.
To define a constant variable.
Which of the following methods is used to handle errors within an 'async/await' function?
.then()
.catch()
.finally()
try...catch block
How can you handle errors inside an async function?
async
By using the throw keyword.
throw
Using a try...catch block.
try...catch
Errors cannot be handled inside async functions.
By calling the .catch() method on the async function itself.
Which built-in JavaScript method allows you to pass an array of arguments to a function, effectively spreading them as individual arguments?
bind()
spread()
call()
apply()
In the context of ES6 classes, what is the purpose of the 'extends' keyword?
It establishes inheritance by creating a subclass that inherits properties and methods from a superclass.
It defines a new static method within a class.
It extends the functionality of a built-in JavaScript object like Array or String.
It's used to create an instance of a parent class.
What does the 'Fetch API' return as the result of a successful network request?
An error object indicating a failed request.
A callback function for handling the response.
The requested data directly as a JavaScript object.
A Promise that resolves to a Response object.
You want to remove the third child element from a parent element with the ID 'container'. What is the correct JavaScript code?
document.getElementById('container').childNodes[2].remove();
document.getElementById('container').children[2].remove();
document.getElementById('container').removeChild(2);
document.getElementById('container').deleteChild(2);
What is the purpose of the .catch() method in Promise chaining?
To transform the resolved value of a Promise.
To handle Promise rejections (errors).
To handle successful Promise resolutions.
To filter the results of a Promise.