Which principle of object-oriented programming focuses on hiding internal implementation details and exposing only necessary information?
Encapsulation
Polymorphism
Abstraction
Inheritance
What is the purpose of the 'performance.now()' method in JavaScript?
It measures the execution time of a specific code block with high precision.
It clears a timer previously set with 'setTimeout'.
It provides the current time in milliseconds since the Unix epoch.
It schedules a function to run after a specified delay.
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').childNodes[2].remove();
document.getElementById('container').deleteChild(2);
document.getElementById('container').removeChild(2);
document.getElementById('container').children[2].remove();
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 return value is passed as the argument.
A reference to the function is passed, allowing it to be invoked later.
The function is executed before being passed as an argument.
The function's code is copied into the receiving function.
What is a common practice to avoid deeply nested callbacks when working with multiple asynchronous operations?
Chaining multiple '.then()' methods together.
Using nested 'try...catch' blocks extensively.
Employing synchronous functions exclusively.
Switching to a different programming language.
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
5
undefined
25
What is the primary purpose of Promises in JavaScript?
To handle synchronous operations more efficiently.
To manage asynchronous operations and their results.
To create loops that iterate over arrays.
To define object-oriented classes.
Consider the code: const myFunc = (a, b) => a + b;. What type of function is myFunc?
const myFunc = (a, b) => a + b;
myFunc
Constructor function
Method
Arrow function
Generator function
What is a primary method for avoiding memory leaks in JavaScript?
Minimizing function calls
Using 'async/await' for all asynchronous operations
Dereferencing unused objects and variables
Using 'const' for all variable declarations
What does the await keyword do inside an asynchronous function?
await
It pauses execution until the Promise it's used with resolves or rejects.
It sets a timeout before executing the next line of code.
It logs an error message to the console.
It defines a new Promise object.