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)?
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)?
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
function A(){
function B(){
}
var F=function(){
B();
}
return F;
}
var X=A();
//Now when u want to use this just use this X function it will work without parsing B()