JS Coding Questions Logo
JS Coding Questions
#395💼 Interview

What are the differences between promises and observables

Advertisement

728x90

Some of the major difference in a tabular form

| Promises | Observables |

| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |

| Emits only a single value at a time | Emits multiple values over a period of time(stream of values ranging from 0 to multiple) |

| Eager in nature; they are going to be called immediately | Lazy in nature; they require subscription to be invoked |

| Promise is always asynchronous even though it resolved immediately | Observable can be either synchronous or asynchronous |

| Doesn't provide any operators | Provides operators such as map, forEach, filter, reduce, retry, and retryWhen etc |

| Cannot be canceled | Canceled by using unsubscribe() method |

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 53

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
395of476
What are the differences between promises and observables | JSCodingQuestions.com