-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync.js
More file actions
44 lines (42 loc) · 925 Bytes
/
async.js
File metadata and controls
44 lines (42 loc) · 925 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
/*********************************
* synchronous
*/
const second = () => {
console.log('Second');
}
const first = () => {
console.log('first');
second();
console.log('end');
}
first();
/***********************************
* asynchronous
*/
console.log('------------------------------------------');
const abc = () => {
setTimeout(() => {
console.log('Async call');
}, 2000);
}
const mnc = () => {
console.log('Starts');
abc();
console.log('ends');
}
mnc();
//-------------------------------------------------------------
function abc1() {
setTimeout(() => {
const q = [123, 234, 345, 456];
console.log('q', q);
setTimeout((id) => {
const res = {
publisher: 'asdfghjkl',
title: 'zxcvbnm'
};
console.log(`${id}--------${res.title}`);
}, 1000, q[2]);
}, 1500);
}
abc1();