Which tool is commonly used for profiling JavaScript code execution and identifying performance bottlenecks?
Chrome DevTools Performance Tab
Array.reduce()
console.time()
JSON.stringify()
Which HTTP status code range generally indicates a successful request made with the Fetch API?
400-499
200-299
100-199
300-399
Which of these methods allows you to explicitly set the this value when calling a function in JavaScript?
this
.map()
.call()
.filter()
.forEach()
In the context of higher-order functions, what does it mean for a function to be passed as an argument to another function?
The function is executed before being passed as an argument.
The function's return value is passed as the argument.
A reference to the function is passed, allowing it to be invoked later.
The function's code is copied into the receiving function.
What is the primary difference between 'nextSibling' and 'nextElementSibling' in DOM traversal?
'nextSibling' might return a text node or comment, while 'nextElementSibling' only returns element nodes.
There is no difference; they are interchangeable.
'nextSibling' traverses upwards in the DOM, while 'nextElementSibling' traverses downwards.
'nextSibling' only works with elements, while 'nextElementSibling' works with any node type.
What is a common practice to avoid deeply nested callbacks when working with multiple asynchronous operations?
Employing synchronous functions exclusively.
Chaining multiple '.then()' methods together.
Using nested 'try...catch' blocks extensively.
Switching to a different programming language.
Consider the code: const myFunc = (a, b) => a + b;. What type of function is myFunc?
const myFunc = (a, b) => a + b;
myFunc
Arrow function
Generator function
Constructor function
Method
How can you ensure that a piece of code runs only after a Promise has been rejected?
By placing the code immediately after the Promise is created.
By using the '.catch()' method.
By using the 'setTimeout()' function.
By using the '.then()' method.
You have a form with client-side validation. What is the recommended approach to prevent form submission if validation fails?
Set the form's 'action' attribute to an empty string.
Use event.stopPropagation() to stop the submission event.
event.stopPropagation()
Remove the 'submit' attribute from the form element dynamically.
Use event.preventDefault() and handle the submission logic manually.
event.preventDefault()
In what scenario would you typically use a callback function?
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 create a loop that iterates a specific number of times.
To define a constant variable.