Last active
March 18, 2020 04:04
-
-
Save vivektikar25/74da66dfbef803ad0f9b1873ae6e78a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function funC() { | |
| var lastName = "Tesla"; | |
| function funB() { | |
| var name = "Bose"; | |
| function funA() { | |
| console.log(name, lastName); | |
| } | |
| } | |
| } | |
| // --=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= // | |
| function outerFunction() { | |
| var count = 10; | |
| return function innerFunction() { | |
| console.log(count); | |
| }; | |
| } | |
| var innerFunc = outerFunction(); | |
| console.dir(innerFunc); | |
| innerFunc(); | |
| // Also try following scenarios -- | |
| // move count to innerFunction. | |
| // then console.dir result. | |
| // add newCount to outerFunction and move count back to outerFunction. | |
| // then console.dir result. | |
| // add newCount to console.log of innerFunction. | |
| // then console.dir result. | |
| // --=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= // | |
| function foo() { | |
| var count = 40; | |
| bar(function param() { | |
| console.log(count); | |
| }); | |
| } | |
| function bar(param) { | |
| var count = 50; | |
| console.dir(param); | |
| param(); | |
| } | |
| foo(); | |
| // --=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= // | |
| function funC() { | |
| var lastName = "Tesla"; | |
| function funB() { | |
| var name = "Bose"; | |
| function funA() { | |
| console.log(name, lastName); | |
| } | |
| console.dir(funA); | |
| funA(); | |
| } | |
| funB(); | |
| } | |
| funC(); | |
| // --=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--= // |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment