Skip to content

Commit 74a1bb6

Browse files
committed
callback hell
1 parent 0891f91 commit 74a1bb6

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

advance js/callback.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//callback hell
2+
3+
function database(id,database){
4+
setTimeout(()=>{
5+
console.log("data of",id)
6+
if(database){
7+
database()
8+
}
9+
},2000)
10+
11+
12+
13+
}
14+
console.log("getting next data 3004")
15+
database(3004,()=>{
16+
console.log("getting next data 3005")
17+
database(3005,()=>{
18+
console.log("getting next data 3006")
19+
database(3006,()=>{
20+
console.log("getting next data 3007")
21+
database(3007)
22+
})
23+
})
24+
})
25+
26+

advance js/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Document</title>
7+
</head>
8+
<body>
9+
hey
10+
<script src="callback.js"></script>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)