Skip to content

Commit 5faaf49

Browse files
authored
Topic 2: Add Promises
1 parent 8fa3271 commit 5faaf49

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ One place JavaScript!
55
### Table of Contents
66

77
- [Callback/ Higher-order Function](#callback)
8+
- [Promises](#promises)
89

910
<a name=“callback”/>
1011

@@ -26,3 +27,17 @@ the callback were defined in the containing function. Hence callback function ha
2627
well as global variables.
2728

2829
[JsFiddle Example](http://jsfiddle.net/varit05/o3vu14kd/)
30+
31+
<a name=“promises”/>
32+
33+
#### Promises
34+
35+
The promise constructor takes one argument, a callback with two parameters, resolve and reject.
36+
Do something within the callback, perhaps async, then call resolve if everything worked, otherwise call reject.
37+
38+
A Promise can be:
39+
1. fulfilled - The action relating to the promise succeeded
40+
2. rejected - The action relating to the promise failed
41+
3. pending - Hasn't fulfilled or rejected yet
42+
4. settled - Has fulfilled or rejected
43+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy