Categories

May 30
Q: What are Promises?

1 Answer

May 30

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)

Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

Madanswer
Jan 13 in Big Data | Hadoop
Jul 2, 2019 in React JS
Jun 30 in Azure
...