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
//? Closure is an important JavaScript pattern to give private access to a variable
17
17
18
-
//Closures :
19
-
//Closure is an important JavaScript pattern to give private access to a variable
20
18
functionclosures(val){
21
-
returnfunction(name){
22
-
console.log(val+" "+name);
23
-
}
19
+
returnfunction(name){
20
+
console.log(val+" "+name);
21
+
};
24
22
}
25
23
constgreet=closures("Hello");
26
24
greet("Kirtti");
27
25
28
-
//In a more real-world scenario, you could envision an initial function apiConnect(apiKey) that returns some methods that would use the API key. In this case, the apiKey would just need to be provided once and never again.
26
+
//* In a more real-world scenario, you could envision an initial function apiConnect(apiKey) that returns some methods that would use the API key. In this case, the apiKey would just need to be provided once and never again.
0 commit comments