Which built-in JavaScript method allows you to pass an array of arguments to a function, effectively spreading them as individual arguments?
apply()
bind()
call()
spread()
How does JavaScript's garbage collector typically identify objects that are no longer reachable?
By using a mark-and-sweep algorithm.
By relying on manual memory deallocation.
By using a reference counting algorithm.
By analyzing the lexical scope of variables.
Which technique can minimize DOM reflows and repaints, leading to smoother UI updates?
Using 'innerHTML' to update large sections of the DOM
Batching DOM updates and using 'requestAnimationFrame'
Frequently reading element properties like 'offsetWidth'
Making changes to elements with 'display: none'
What is a common practice to avoid deeply nested callbacks when working with multiple asynchronous operations?
Employing synchronous functions exclusively.
Chaining multiple '.then()' methods together.
Switching to a different programming language.
Using nested 'try...catch' blocks extensively.
Which tool is commonly used for profiling JavaScript code execution and identifying performance bottlenecks?
console.time()
Array.reduce()
JSON.stringify()
Chrome DevTools Performance Tab
How can you ensure that a piece of code runs only after a Promise has been rejected?
By using the '.catch()' method.
By placing the code immediately after the Promise is created.
By using the 'setTimeout()' function.
By using the '.then()' method.
How does the 'bind()' method in JavaScript differ from 'call()' and 'apply()'?
bind() immediately invokes the function, while call() and apply() don't.
bind() doesn't modify the original function, while call() and apply() do.
bind() creates a new function with a bound 'this' context, while call() and apply() invoke the function immediately.
bind() can only be used with object methods, while call() and apply() can be used with any function.
Which of the following methods is used to handle errors within an 'async/await' function?
.catch()
.then()
try...catch block
.finally()
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
25
undefined
10
What is the primary difference between 'nextSibling' and 'nextElementSibling' in DOM traversal?
'nextSibling' might return a text node or comment, while 'nextElementSibling' only returns element nodes.
There is no difference; they are interchangeable.
'nextSibling' traverses upwards in the DOM, while 'nextElementSibling' traverses downwards.
'nextSibling' only works with elements, while 'nextElementSibling' works with any node type.