Which keyword is used to define an asynchronous function in JavaScript?
promise
async
sync
await
What is a primary method for avoiding memory leaks in JavaScript?
Minimizing function calls
Using 'const' for all variable declarations
Dereferencing unused objects and variables
Using 'async/await' for all asynchronous operations
Which built-in JavaScript method allows you to pass an array of arguments to a function, effectively spreading them as individual arguments?
call()
apply()
bind()
spread()
What does the await keyword do inside an asynchronous function?
It defines a new Promise object.
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.
How can you ensure that a piece of code runs only after a Promise has been rejected?
By using the '.catch()' method.
By using the '.then()' method.
By placing the code immediately after the Promise is created.
By using the 'setTimeout()' function.
Which principle of object-oriented programming focuses on hiding internal implementation details and exposing only necessary information?
Encapsulation
Polymorphism
Abstraction
Inheritance
Which of the following methods is used to handle errors within an 'async/await' function?
.finally()
try...catch block
.catch()
.then()
Which method allows you to move up from a child element to its direct parent in the DOM?
closest()
previousSibling
parentNode
parentElement
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 extends the functionality of a built-in JavaScript object like Array or String.
It's used to create an instance of a parent class.
It defines a new static method within a class.
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));
25
5
10
undefined