1D0-720 · Question #80
In JavaScript, how are promises used?
The correct answer is B. To handle potential future results of an operation. Promises in JavaScript represent the eventual completion (or failure) of an asynchronous operation, making B correct - they let you handle results that aren't available yet, such as a network request or a timer. Options A, C, and D describe unrelated JavaScript/web concepts…
Question
In JavaScript, how are promises used?
Options
- ATo iterate over arrays.
- BTo handle potential future results of an operation.
- CTo style HTML elements.
- DTo create new HTML elements.
How the community answered
(33 responses)- A3% (1)
- B94% (31)
- C3% (1)
Explanation
Promises in JavaScript represent the eventual completion (or failure) of an asynchronous operation, making B correct - they let you handle results that aren't available yet, such as a network request or a timer. Options A, C, and D describe unrelated JavaScript/web concepts: array iteration uses methods like forEach or for...of, styling elements is done via CSS or the style property, and creating DOM elements uses document.createElement().
Memory tip: Think of a promise like ordering food at a restaurant - you receive a "promise" (the ticket) now, and you handle the result later when the food either arrives (.then()) or the kitchen fails (.catch()).
Topics
Community Discussion
No community discussion yet for this question.