What is a promise in JavaScript?
a) An object representing the eventual completion or failure of an asynchronous operation
b) A function that always resolves
c) A callback function
d) A synchronous operation
Answer:
a) An object representing the eventual completion or failure of an asynchronous operation
Explanation:
A promise in JavaScript is an object that represents the eventual completion (or failure) of an asynchronous operation. It allows you to handle asynchronous tasks like fetching data or performing calculations in a non-blocking manner.