What is the primary role of the this keyword in JavaScript?
this
It accesses the global scope.
It creates a new object instance.
It refers to the current date and time.
It points to the object that the function is a property of, determined at function call time.
In JavaScript, how does the prototype chain relate to object inheritance?
The prototype chain manages asynchronous tasks related to object creation.
The prototype chain determines the order of function execution within an object.
It establishes a hierarchy for property and method lookup, enabling objects to inherit from prototypes.
It's used for event handling and propagation within the DOM.
What is the purpose of 'event.preventDefault()' in JavaScript?
It prevents the default behavior of an element, like a form submission.
It stops an event from being handled by any further listeners.
It removes an event listener from an element.
It triggers a custom event on an element.
How can you handle errors inside an async function?
async
Errors cannot be handled inside async functions.
Using a try...catch block.
try...catch
By using the throw keyword.
throw
By calling the .catch() method on the async function itself.
.catch()
Which built-in JavaScript method allows you to pass an array of arguments to a function, effectively spreading them as individual arguments?
apply()
call()
spread()
bind()
Which HTTP status code range generally indicates a successful request made with the Fetch API?
300-399
100-199
200-299
400-499
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
undefined
10
25
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.
How do modules enhance code organization and reusability in JavaScript?
They allow developers to group related code into separate files and control their visibility and accessibility, reducing global scope pollution.
Modules primarily handle data persistence in JavaScript applications.
They are used for creating user interfaces and handling user interactions.
Modules enable asynchronous programming, improving the performance of web applications.
Which of the following methods is used to handle errors within an 'async/await' function?
try...catch block
.then()
.finally()