lets take this example
function main (x) {
return x
}
function second() {
console.log("hello ")
}
js compiler knows all function declarations so I can call second
inside main
main(second())
what I dont get about recursive functions is that how the same function can be called inside the function declaration
function factorial(n) {
if (n ===1) {
return 1;
} else {
return n * factorial(n-1);
}
}
my thought process is: okay this is the function declaration this is what the function does, but how can
can i call the same function even if the declaration is not finished