Skip to content

Commit 78bc322

Browse files
committed
add all 94-callback-function till line no 56
1 parent 49e1a08 commit 78bc322

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

94-callback-function.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>Callback function</title>
9+
<link rel="stylesheet" type="text/css" href="">
10+
</head>
11+
12+
<body>
13+
14+
<script src="js/94-callback-function.js"></script>
15+
</body>
16+
17+
</html>

js/94-callback-function.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//abhi tak humne variable ko as a argument pass kiya hain
2+
/*
3+
function add(num1, num2) {
4+
console.group(num1 + num2);
5+
}
6+
7+
8+
add(10, 20); //30
9+
10+
11+
//callback function se ek function k andr dusra function kaise pass karte hain as a parameter
12+
13+
14+
function sayhello() {
15+
console.log("Hello");
16+
}
17+
function add(num1, num2, callback) { //callback name se sayhello function receive hoga
18+
// sayhello(); //hum direct kyon nhi call kar liye sayhello function ko
19+
console.group(num1 + num2);
20+
callback();
21+
}
22+
23+
24+
let a = 10;
25+
let b = 20;
26+
27+
add(a, b, sayhello); //30 //Hello
28+
29+
//callback function benefit is we can pass 2 functiondirectly even with diffrent parameter. but diirect function call karne se ek hi function calll hoga. parameter v nhi change kar sakte hain.
30+
31+
32+
//ye ajax,asynchronus m kam aata hain, mostly
33+
34+
35+
//hum callback function as a ananymous function v pass akr sakte hain.
36+
37+
//ananomus function normal and arrow function se bana sakte hain.
38+
*/
39+
//ananomus function v pass kr sakte hain as a parameter. sbse jyda anonumus function use karte hain call back function m
40+
function sayhello() {
41+
console.log("Hello");
42+
}
43+
function add(num1, num2, callback) {
44+
console.group(num1 + num2);
45+
callback();
46+
}
47+
48+
49+
let a = 10;
50+
let b = 20;
51+
52+
add(a, b, sayhello); //30 //Hello
53+
54+
add(30, 5, function () {
55+
console.log("Bye..........."); //Bye...........
56+
});

0 commit comments

Comments
 (0)