JSFiddle - React, Tailwind, and code Playground
by 3gwebtrain
JavaScript
var foo = (function () {
var bar = function () {
//this is called private function not sub function
//it is only possible to access from the object you written down.
//it can't communicate out side of `foo` other than the way of function your return down.
return "Venkat";
}
return function () { //you are retuning a function to access a prive function "bar" here.
return bar();
};
}()); //you are self invoking a function to return another function.
var x = foo();//you are calling returned function.
console.log(x); //it will be venkat.