I am using more and more javascript in my work and wonders what is good practice when it comes to the examples below.
function foo(){
//do stuf
var bar = foo2();
//do stuf
function foo2(){
//do stuf
return aValue;
}
}
No other functions needs to know about foo2()
which is why I sometimes hides it in foo()
. The downside is that I think that readability of foo()
is lost and it could be harder to locate foo2()
. Is this good practice or should I rather do it like this:
function foo(){
//do stuf
var bar = foo2();
//do stuf
}
function foo2(){
//do stuf
return aValue;
}