Skip to content

Instantly share code, notes, and snippets.

@vivektikar25
Last active March 18, 2020 04:04
Show Gist options
  • Select an option

  • Save vivektikar25/74da66dfbef803ad0f9b1873ae6e78a3 to your computer and use it in GitHub Desktop.

Select an option

Save vivektikar25/74da66dfbef803ad0f9b1873ae6e78a3 to your computer and use it in GitHub Desktop.
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