looking at the introduction to ES6 written by Ruan Yifeng, I found that there was a contradiction in the content.
As mentioned in
, tail call optimization is only enabled in strict mode, but I use it to call optimized code to run normally without strict mode, and I do use tail call optimization.
function Fibonacci2 (n , ac1 = 1 , ac2 = 1) {
if( n <= 1 ) {return ac2};
return Fibonacci2 (n - 1, ac2, ac1 + ac2);
}
Fibonacci2(100) // 573147844013817200000
Fibonacci2(1000) // 7.0330367711422765e+208
Fibonacci2(10000) // Infinity
I can really run out quickly when I run locally. It doesn"t get stuck. It"s really optimized, but there"s no strict mode on here
.