JSFiddle - React, Tailwind, and code Playground
by Kaushik Ruparel
JavaScript
//example where 2 functions share the same variable
/*var child;
var parent = function () {
var a = 10;
child = function () {
console.log("from child " + a);
};
console.log("from parent " + a);
};
parent();
child();
*/
function outer(value) {
var shared = value;
var inner1 = function () {
console.log("from inner1: " + shared);
};
var inner2 = function () {
console.log("from inner2: " + shared);
};
return [inner1,inner2];
}
funcs = outer(15);
funcs[0]();
funcs[1]();
//var a = outer(10);
//a.inner1();