This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is just a short reminder of this great explanation: | |
| // http://www.2ality.com/2015/06/tail-call-optimization.html | |
| // not TCO | |
| function factorial(n) { | |
| if (n <= 0) return 1; | |
| return n * factorial(n-1); // here, the main recursive call not in a tail position because of the `n` context. | |
| } |