I was just experimenting with some recursion and noticed something that confused me. Let me illustrate with some code examples:
function loop(x) {
if (x >=
When using the function without the second return statement, the function yields no value to the callee per definition in JavaScript returns undefined.
So using the first definition and for example loop(9):
0 < 10, so we don't execute the if-clause body, but just call loop(10).loop(10) returns 10, but we never use this value.undefined.