-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPromise.js
More file actions
33 lines (22 loc) · 836 Bytes
/
Promise.js
File metadata and controls
33 lines (22 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Promise is a way to handle asynchronous operations in JavaScript.
// It allows handlers with an asynchronous action's eventual success value or failure reason.
// the asynchronous method returns a promise to supply the value at some point in the future.
// A Promise is in one of these states:
// Pending: initial state, neither fulfilled nor rejected.
// Fulfilled: meaning that the operation completed successfully.
// Rejected: meaning that the operation failed.
const callBack = (err, success) => {
if (err) {
console.log(err)
} else {
console.log(success)
}
}
// CallBack Function
const doSomething = callback => {
setTimeout(() => {
const skills = ["HTML", "Reactjs", "Nodejs"]
console.log("it will call you back", skills)
}, 3000)
}
doSomething(callBack)