Which of these methods allows you to explicitly set the this value when calling a function in JavaScript?
this
.forEach()
.filter()
.call()
.map()
What is a key difference between 'async/await' and traditional Promise-based code?
'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.
'async/await' doesn't use Promises internally.
What is the impact of long-running JavaScript tasks on the browser's responsiveness?
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.
They enhance user experience by providing smoother animations and transitions.
They have no significant impact on browser responsiveness, as JavaScript execution is asynchronous.
Which method is most efficient for finding a specific element in the DOM based on its ID?
getElementById('my-id')
querySelector('#my-id')
getElementsByClassName('my-class')[0]
querySelectorAll('#my-id')[0]
Which of the following is NOT a valid HTTP method used with the Fetch API?
CONNECT
POST
DELETE
GET
Which tool is commonly used for profiling JavaScript code execution and identifying performance bottlenecks?
Chrome DevTools Performance Tab
JSON.stringify()
console.time()
Array.reduce()
Which method allows you to move up from a child element to its direct parent in the DOM?
parentNode
parentElement
previousSibling
closest()
How does JavaScript's garbage collector typically identify objects that are no longer reachable?
By analyzing the lexical scope of variables.
By using a reference counting algorithm.
By using a mark-and-sweep algorithm.
By relying on manual memory deallocation.
How do ES6 classes simplify object-oriented programming in JavaScript compared to constructor functions?
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.
ES6 classes introduce a completely new inheritance model unrelated to prototypes.
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').removeChild(2);
document.getElementById('container').deleteChild(2);
document.getElementById('container').children[2].remove();