Which keyword is used to define an asynchronous function in JavaScript?
sync
await
async
promise
How can you ensure that the 'this' keyword inside a callback function refers to the intended object, especially in asynchronous operations?
By wrapping the callback function in another function.
By using the 'let' keyword to declare variables inside the callback.
By using arrow functions, which lexically inherit the 'this' value.
By invoking the callback function with 'call()' or 'apply()'.
Which HTTP status code range generally indicates a successful request made with the Fetch API?
300-399
400-499
200-299
100-199
In JavaScript's event loop, what is the role of the 'microtask queue'?
It executes tasks that have been explicitly delayed with setTimeout.
It processes promises and other tasks with higher priority than the main task queue.
It manages network requests and responses.
It handles user interactions like clicks and scrolls.
What will be logged to the console in this code snippet: console.log((function(a) { return a * a; })(5));?
console.log((function(a) { return a * a; })(5));
5
10
25
undefined
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').removeChild(2);
document.getElementById('container').children[2].remove();
document.getElementById('container').deleteChild(2);
document.getElementById('container').childNodes[2].remove();
What is the primary purpose of constructor functions in JavaScript?
To create multiple instances of an object with shared properties and methods.
To handle asynchronous operations.
To define static methods for a class.
To define private variables within a function scope.
How can you handle errors inside an async function?
By calling the .catch() method on the async function itself.
.catch()
Using a try...catch block.
try...catch
Errors cannot be handled inside async functions.
By using the throw keyword.
throw
What does the await keyword do inside an asynchronous function?
It sets a timeout before executing the next line of code.
It logs an error message to the console.
It pauses execution until the Promise it's used with resolves or rejects.
It defines a new Promise object.
What is a higher-order function in JavaScript?
A function that uses arrow syntax.
A function that does not have a return statement.
A function that can only be called once.
A function that takes another function as an argument or returns a function.