Skip to content

Commit 10b9703

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

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

CoreFundamentals/3Closures.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,13 @@ function outer(){
7070
}
7171
outer()(); //30
7272
//As closure in not dependent on the style of declaration. it binds function and lexical scope.
73+
74+
//It also works with let and const
75+
function outer(){
76+
function inner(){
77+
console.log(a);
78+
}
79+
let a=200;
80+
return inner;
81+
}
82+
outer()(); //200

0 commit comments

Comments
 (0)