Nested functions have access to their parent scope so you could change state in a parent's scope from a deeply nested function. For example
function one() {
var a = 1;
two(); // a = 4
function two() {
var b = 2;
three(); // b = 4
function three() {
var c = 3;
four(); // c = 4
function four() {
a = 4;
b = 4;
c = 4;
}
}
}
}
On one hand this is pretty powerful. On the other hand it can easily get sloppy and hard to reason about because you have to make sure any child function hasn't changed a value in any of its parents.
If you stick to not nesting your functions you won't have to worry that the state inside your function is being changed from inside of a nested function.
function one() {
var a = 1;
two(); // a = 1
}
function two() {
var b = 2;
three(); // b = 2
}
function three() {
var c = 3;
four(); // c = 3
}
function four() {
a = 4;
b = 4;
c = 4;
}