+1 vote
by
What are Promises?

1 Answer

0 votes
by

Promises are a concurrency primitive, first described in the 80s. Now they are part of most modern programming languages to make your life easier. Promises can help you better handle async operations.

An example can be the following snippet, which after 100ms prints out the result string to the standard output. Also, note the catch, which can be used for error handling. Promises are chainable.

new Promise((resolve, reject) => {

  setTimeout(() => {

    resolve('result')

  }, 100)

})

  .then(console.log)

  .catch(console.error)

Related questions

0 votes
asked Oct 28, 2023 in JavaScript by DavidAnderson
0 votes
asked Mar 5, 2022 in Apache Oozie by rajeshsharma
...