First of all, I am asking this out of sheer curiosity, it has no real application where this would be useful (or do I know?).
I know that it is possible to make a function return another function, and that the returned function can be a parameter, that is.
function a(b) {
return b();
}
So, if I pass a function inside function "a", it returns the return of the function that was used as parameter after its execution. Exemplifying again:
function foo() {
return 'bar';
}
console.log(a(foo)); // printa 'bar'
Until then, okay.
However, and when I try to invoke the function a
within itself?
a(a); // erro
I've tried, and the answer is an error reporting b is not a function
.
I wanted to understand how / why this occurs. In my head he should get into an infinite processing cycle, and lock, or something. Did I let something happen?