-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path134.js
More file actions
48 lines (36 loc) · 787 Bytes
/
Copy path134.js
File metadata and controls
48 lines (36 loc) · 787 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Promise
console.log("script start");
const bucket = ['coffee', 'chips', 'vegetables', 'salt', 'rice'];
const friedRicePromise = new Promise((resolve, reject) =>
{
if (bucket.includes("vegetables") && bucket.includes("salt") && bucket.includes("rice"))
{
resolve({ value: "friedrice" });
} else
{
reject("could not do it");
}
})
// produce
// consume
// how to consume
friedRicePromise.then(
// jab promise resolve hoga
(myfriedRice) =>
{
console.log("lets eat ", myfriedRice);
}
).catch(
(error) =>
{
console.log(error)
})
setTimeout(() =>
{
console.log("hello from settimeout")
}, 0)
for (let i = 0; i <= 100; i++)
{
console.log(Math.random(), i);
}
console.log("script end!!!!")