You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//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
0 commit comments