Which principle of object-oriented programming focuses on hiding internal implementation details and exposing only necessary information?
Inheritance
Encapsulation
Abstraction
Polymorphism
Which built-in JavaScript method allows you to pass an array of arguments to a function, effectively spreading them as individual arguments?
call()
bind()
apply()
spread()
What is a common practice to avoid deeply nested callbacks when working with multiple asynchronous operations?
Switching to a different programming language.
Chaining multiple '.then()' methods together.
Using nested 'try...catch' blocks extensively.
Employing synchronous functions exclusively.
What is a key difference between 'async/await' and traditional Promise-based code?
'async/await' doesn't use Promises internally.
'async/await' provides a more synchronous-looking syntax for asynchronous code.
'async/await' is significantly slower than using Promises directly.
'async/await' is suitable for handling synchronous operations only.
Which method is most efficient for finding a specific element in the DOM based on its ID?
getElementById('my-id')
querySelectorAll('#my-id')[0]
querySelector('#my-id')
getElementsByClassName('my-class')[0]
How do ES6 classes simplify object-oriented programming in JavaScript compared to constructor functions?
ES6 classes introduce a completely new inheritance model unrelated to prototypes.
ES6 classes are primarily used for working with the DOM and have limited object-oriented capabilities.
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.
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
undefined
10
What is the impact of long-running JavaScript tasks on the browser's responsiveness?
They have no significant impact on browser responsiveness, as JavaScript execution is asynchronous.
They enhance user experience by providing smoother animations and transitions.
They improve rendering performance by allowing the browser to optimize resource allocation.
They can block the main thread, leading to a frozen UI and unresponsive interactions.
How can you ensure that a piece of code runs only after a Promise has been rejected?
By using the '.then()' method.
By using the '.catch()' method.
By placing the code immediately after the Promise is created.
By using the 'setTimeout()' function.
Which tool is commonly used for profiling JavaScript code execution and identifying performance bottlenecks?
Chrome DevTools Performance Tab
Array.reduce()
JSON.stringify()
console.time()