Skip to content

Commit 80b3aaf

Browse files
authored
Update 3Closures.js
1 parent e8b69f7 commit 80b3aaf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

CoreFundamentals/3Closures.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,15 @@ function outer(){
5858
}
5959
}
6060
outer()(); //30
61+
62+
//This also forms a closure
63+
function outer(){
64+
65+
function inner(){
66+
console.log(a);
67+
}
68+
var a=30;
69+
return inner;
70+
}
71+
outer()(); //30
72+
//As closure in not dependent on the style of declaration. it binds function and lexical scope.

0 commit comments

Comments
 (0)