23

Possible Duplicate:
What are the differences between Deferred, Promise and Future in Javascript?

Can someone point out what are the differences are between callbacks and promises? When should one use promise etc?

Also links on how to create and use promises will be appreciated.

0

1 Answer 1

44

Promises provide a more succinct and clear way of representing sequential asynchronous operations in javascript. They are effectively a different syntax for achieving the same effect as callbacks. The advantage is increased readability. Something like this

aAsync() .then(bAsync) .then(cAsync) .done(finish); 

is much more readable then the equivalent of passing each of those individual functions as callbacks, like

Async(function(){ return bAsync(function(){ return cAsync(function(){ finish() }) }) }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.