-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path48 asynchronous.js
More file actions
60 lines (45 loc) · 1.11 KB
/
48 asynchronous.js
File metadata and controls
60 lines (45 loc) · 1.11 KB
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
57
// ***************Asynchronous JavaScript***************
//semple callback function
console.log("semple callback");
function show(params) {
console.log("RANA ABOBAKAR");
}
function call(callback) {
callback();
}
call(show);
console.log("after");
// **************Waiting for a Timeout*******************
//asynchronuos
// When using the JavaScript function setTimeout(), you can specify a callback function to be executed on time-out:
function show1(params) {
console.log("asynchronus function");
}
setTimeout(show1,3000);
console.log("before");
console.log("method 2");
//method 2
setTimeout(function () {
show2("asinchronus method 2");
},2000);
function show2(params) {
console.log(params);
}
// method 3
console.log("method 3");
setTimeout(()=>show2("arrow function"),3000);
/*
Waiting for Intervals:
When using the JavaScript function setInterval(), you can specify a callback function to be executed for each interval:
*/
const axios=require("axios");
var a=0;
let x=setInterval(show22,3000);
function show22() {
console.log("RANA ABOBAKAR");
a++;
if(a==3)
{
clearInterval(x);
}
}