Function definition inside function

javascript

Solution

If you want use a function only internally, how about closure. Here an example

    var A = (function () {
    var publicFun = function () { console.log("I'm public"); }
    var privateFun2 = function () { console.log("I'm private"); }

    console.log("call from the inside");
    publicFun();
    privateFun2();

    return {
        publicFun: publicFun
    }
})();   

console.log("call from the outside");
A.publicFun();
A.privateFun(); //error, because this function unavailable

Problem

If i have code: ``` function A() { function B() { } B(); } A(); A(); ``` is B function parsed and created each time i call A(so it can decrease performance of A)?

Original source

Related problems