What is the impact of long-running JavaScript tasks on the browser's responsiveness?
They improve rendering performance by allowing the browser to optimize resource allocation.
They have no significant impact on browser responsiveness, as JavaScript execution is asynchronous.
They can block the main thread, leading to a frozen UI and unresponsive interactions.
They enhance user experience by providing smoother animations and transitions.
Which of the following is NOT a valid HTTP method used with the Fetch API?
DELETE
GET
POST
CONNECT
Which HTTP status code range generally indicates a successful request made with the Fetch API?
300-399
200-299
100-199
400-499
Which of these methods allows you to explicitly set the this value when calling a function in JavaScript?
this
.map()
.call()
.forEach()
.filter()
In what scenario would you typically use a callback function?
To define a constant variable.
To perform an action after an asynchronous operation completes, like fetching data from an API.
To create a loop that iterates a specific number of times.
To log data to the console for debugging purposes.
Which method allows you to move up from a child element to its direct parent in the DOM?
parentNode
parentElement
closest()
previousSibling
What is the purpose of the response.json() method when using the Fetch API?
response.json()
It parses the response body as JSON data.
It sends a JSON-encoded request to the server.
It converts a JavaScript object into a JSON string.
It sets the Content-Type header of the request to 'application/json'.
What is a common way to achieve encapsulation in JavaScript when modules are not an option (e.g., in older environments)?
Leveraging closures to create private scopes and control access to variables and functions within those scopes.
Encapsulation is not achievable without modules in JavaScript.
Relying solely on comments to indicate private members, as there are no built-in mechanisms for true privacy.
Using global variables to store private data.
How can you ensure that a piece of code runs only after a Promise has been rejected?
By using the 'setTimeout()' function.
By placing the code immediately after the Promise is created.
By using the '.catch()' method.
By using the '.then()' method.
What is the purpose of 'event.preventDefault()' in JavaScript?
It stops an event from being handled by any further listeners.
It prevents the default behavior of an element, like a form submission.
It removes an event listener from an element.
It triggers a custom event on an element.