DEV Community

Cover image for Promises Promises
Doug Jones
Doug Jones

Posted on

Promises Promises

I was recently in an interview for javascript and was asked what I though was an easy question.

The interviewer ask me to explain promises.

...Well I though inside this is easy... I got this.

...Welp needless to say things didn't go as I expected.

What are Promises in JavaScript

question mark

Promises are objects used to run code asynchronously.

async promise in javascript.

To keep in simple. We can defer the completion of a block of code until the async request is complete.

Promises also have what I like to call a fail safe in the .catch method. Which simply put will catch the errors in our async call.

js promises flow chart

Promises are becoming more useful with us running more and more things asynchronously. Having the ability to catch our errors in one place is extremely important as we develop as developers.

I hope this helps and if you get this question in an interview..good luck

Happy Coding πŸ‘¨πŸΏβ€πŸ’»πŸ‘¨πŸ»β€πŸ’»πŸ‘©β€πŸ’»πŸ§‘πŸΎβ€πŸ’»

Top comments (0)