A Promise in JavaScript is an object that represents the future result of an asynchronous operation, like fetching data, waiting for a timer, or reading a file.
It can be in one of three states: pending, fulfilled, or rejected.
new Promise(...)creates a new promiseresmeans resolve,rejmeans rejectrej()makes the promise fail.then()runs only when the promise is fulfilled.catch()runs when the promise is rejected
Analysis()represents an analysis operation that takes 3 seconds. After the analysis finishes,res()tells JavaScript: "The work is completed successfully."This waits for 3000 milliseconds = 3 seconds.



Top comments (0)