What's Promise?Promise is a constructor. I had a hard time wrapping my head around it at first. I will try to explain the concept. :)
When it comes to programming, it is important to apply the concept in everyday situations. Explanation / AnalogyLet's say, you are about to watch World Cup finals: Russia vs. Brazil.
Scenario 1: Brazil is predicted to win, that is the promise. Now, there are only 2 possible outcomes (win or lose). Scenario 2: Russia wins the match. Therefore Brazil is rejected the win. How does it work?
|
Sample code |