Closures are functions that refer to independent (free) variables. In other words, the function defined in the closure 'remembers' the environment in which it was created.
```js
-functioninit() {
-var name ="Mozilla"; // name is a local variable created by init
-functiondisplayName() { // displayName() is the inner function, a closure
-alert(name); // use variable declared in the parent function
- }
-displayName();
-};
-init();
+functionmakeFunc() {
+var name ="Mozilla";
+functiondisplayName() {
+alert(name);
+ }
+return displayName;
+}
+
+var myFunc =makeFunc();
+myFunc();
```
See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures)
0 comments on commit
c11eb8f