-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassesment.js
56 lines (47 loc) · 887 Bytes
/
assesment.js
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
49
50
51
52
53
54
55
56
//promise function
let myPromise = new Promise(function (myResolve, myReject) {
let x = 1;
// The producing code (this may take some time)
if (x == 0) {
myResolve("OK");
} else {
myReject("Error");
}
});
myPromise.catch(
function (value) {
console.log(value);
},
function (error) {
console.log(error);
}
);
//asynchronous
async function myFunction() {
return "Hello";
}
myFunction().then(
function (value) {
console.log(value);
},
function (error) {
console.log(error);
}
);
//await
async function myDisplay() {
let myPromise = new Promise(function (resolve, reject) {
resolve("Kirtti");
});
console.log(await myPromise);
}
myDisplay();
//
function myFirst() {
console.log("Kirttinath");
}
function mySecond() {
console.log("Goodbye");
}
mySecond(); //this will execute first
myFirst(); //second this is execute