-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallback1.html
More file actions
49 lines (32 loc) · 837 Bytes
/
Copy pathcallback1.html
File metadata and controls
49 lines (32 loc) · 837 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
49
<script>
// function task1(){
// console.log("this is task1!");
// }
// function task2(){
// console.log("this is task2!");
// }
// task1();
// task2();
//using time interval
// function task3(){
// setTimeout( function(){
// console.log("task 3 running!");
// }, 500 );
// }
// function task4(){
// console.log("task 4 running!");
// }
// task3();
// task4();
//now create a callback for this
function taskRun(task, callback) {
callback();
console.log(`${task} from outter is running!`);
}
taskRun('task 1', function () {
taskRun('task 3',function(){
console.log(`task 4 is running!`);
});
console.log(`task 2 is running!`);
});
</script>