No worries @avalander
. You all did right, it is just JS doesn't support TCO there were some attempts (as far as I remember it is hold back by Microsoft member or committee or something like that). There is still way around - you can use trampoline
I doubt you would want to use this in production, but just to make a point.
TCO - stands for tail call optimisation, to prevent Maximum call stack error
Trampoline is the way how some compilers implement TCO, they convert recursion to a loop
No worries @avalander . You all did right, it is just JS doesn't support TCO there were some attempts (as far as I remember it is hold back by Microsoft member or committee or something like that). There is still way around - you can use trampoline
I doubt you would want to use this in production, but just to make a point.
TCO - stands for tail call optimisation, to prevent Maximum call stack error
Trampoline is the way how some compilers implement TCO, they convert recursion to a loop
UPD: read about TCO status in Chrome here stackoverflow.com/questions/427881...
Wow, that's great, I didn't know this trick, thank you!