crackyourinterview.com


To improves our performance please Like Share Subscribe(Will boost us)

Can you write difference between Promises and Observables
Question Posted on 01 May 2020Home >> JavaScript >> JavaScript Questions >> Can you write difference between Promises and Observables

Can you write difference between Promises and Observables
Before going directly to difference between these two i will discuss something about asynchronous features in the JavaScript. Here we know flow of program occurs independently in computer this is called Asynchrony. And this does not wait for a task to get finished and moved moves to the next task.Now question arise we will be take care of this unfinished task. SO answer is background co-worker works handle those unfinished tasks. And another questions is who will handle the data that is returned and answer is Promises, Observables, callbacks and many more of them.

Now move to difference between these 2:-
Promises
(1)Promises are used to handling async requests
(2)Promises are not lazy like observables and promises are execute immediately.
(3)Promise can only provide a single value
(4)We cannot cancel promise becasue cancel feature is not there
(5)promises does not have any operators in their bucket

Observables
(1)Observable are also used to handle asyn requests
(2)Observable are very lazy so we have to subscribe observable to get the results.
(3)On the other hand observable can handle multiple values and also give multiple values.
(4)We can cancel observables by unsubscribing it using the unsubscribe method
(5)There are many operators like map, forEach, filter etc in observables
0
0



.


Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions

regular expression for credit card like VISA, MASTER, AMEX

How to remove item from dropdownlist in Javascript

Different Data Types in Javascript in 2015?

syntax to get dropdownlist text in javascript

The snippet that has to be used to check if “a” is not equal to “null” is _________






@2014-2022 Crackyourinterview (All rights reserved)
Privacy Policy - Disclaimer - Sitemap