What is a key difference between 'async/await' and traditional Promise-based code?
'async/await' is suitable for handling synchronous operations only.
'async/await' doesn't use Promises internally.
'async/await' is significantly slower than using Promises directly.
'async/await' provides a more synchronous-looking syntax for asynchronous code.
What is the primary purpose of constructor functions in JavaScript?
To handle asynchronous operations.
To create multiple instances of an object with shared properties and methods.
To define static methods for a class.
To define private variables within a function scope.
Which principle of object-oriented programming focuses on hiding internal implementation details and exposing only necessary information?
Encapsulation
Abstraction
Inheritance
Polymorphism
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
10
undefined
5
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()
Which method is most efficient for finding a specific element in the DOM based on its ID?
getElementById('my-id')
getElementsByClassName('my-class')[0]
querySelector('#my-id')
querySelectorAll('#my-id')[0]
How do ES6 classes simplify object-oriented programming in JavaScript compared to constructor functions?
Classes eliminate the need for prototypes, making object creation more efficient.
Classes offer a more concise and familiar syntax for defining objects and inheritance, though they still utilize prototypes under the hood.
ES6 classes are primarily used for working with the DOM and have limited object-oriented capabilities.
ES6 classes introduce a completely new inheritance model unrelated to prototypes.
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 sets the Content-Type header of the request to 'application/json'.
It converts a JavaScript object into a JSON string.
It sends a JSON-encoded request to the server.
Which method allows you to move up from a child element to its direct parent in the DOM?
closest()
previousSibling
parentNode
parentElement
How can you ensure that the 'this' keyword inside a callback function refers to the intended object, especially in asynchronous operations?
By using the 'let' keyword to declare variables inside the callback.
By using arrow functions, which lexically inherit the 'this' value.
By wrapping the callback function in another function.
By invoking the callback function with 'call()' or 'apply()'.