I'm trying to incorporate some crazy callback-recursion combo into my Node.js app. After some research, I found a strange syntax to both declare and execute function in the same block. So I try this simple code to test the concept:
(function hello() {
console.log("Hello, world!");
})();
hello();
I expect it to just put two Hello, world!
's in the console. One immediately after declaration and one for the hello()
call. However, it just prints one and then throws an error saying hello is not defined
at hello()
.
Is there something I'm not getting here?