Skip to content

Commit 530ea06

Browse files
authored
Update 3Closures.js
1 parent 531ba84 commit 530ea06

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

CoreFundamentals/3Closures.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,26 @@
2525
console.log(check); //[Function: inf]
2626
console.log(check()); //Sum is 50
2727
console.dir(check); //[Function: inf]
28+
29+
30+
function x(){
31+
var a=7;
32+
return function y(){
33+
console.log(a);
34+
}
35+
a=100;
36+
console.log("hello");
37+
}
38+
var z=x();
39+
z(); //7
40+
41+
function x(){
42+
var a=7;
43+
function y(){
44+
console.log(a);
45+
}
46+
a=100;
47+
return y;
48+
}
49+
var z=x();
50+
z(); //100

0 commit comments

Comments
 (0)