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.
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.
Classes offer a more concise and familiar syntax for defining objects and inheritance, though they still utilize prototypes under the hood.
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));
10
25
5
undefined
What is the primary purpose of constructor functions in JavaScript?
To define static methods for a class.
To define private variables within a function scope.
To create multiple instances of an object with shared properties and methods.
To handle asynchronous operations.
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?
.then()
try...catch block
.catch()
.finally()
In JavaScript, how does the prototype chain relate to object inheritance?
It's used for event handling and propagation within the DOM.
The prototype chain manages asynchronous tasks related to object creation.
It establishes a hierarchy for property and method lookup, enabling objects to inherit from prototypes.
The prototype chain determines the order of function execution within an object.
What is the purpose of the .catch() method in Promise chaining?
To handle successful Promise resolutions.
To filter the results of a Promise.
To transform the resolved value of a Promise.
To handle Promise rejections (errors).
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's code is copied into the receiving function.
The function's return value is passed as the argument.
The function is executed before being passed as an argument.
A reference to the function is passed, allowing it to be invoked later.
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.preventDefault() and handle the submission logic manually.
event.preventDefault()
Remove the 'submit' attribute from the form element dynamically.
Use event.stopPropagation() to stop the submission event.
event.stopPropagation()
Consider the code: const myFunc = (a, b) => a + b;. What type of function is myFunc?
const myFunc = (a, b) => a + b;
myFunc
Constructor function
Generator function
Arrow function
Method