JavaScriptには、再帰が実装されている。 再帰とは、関数のなかでその関数自身を呼び出すこと。 下記のrecursion()では、再帰を行っている。 function recursion(num, limit){ console.log(num); if(num === limit){ return; }; num++; recursion(num, limit); }; recursion(0, 10);を実行すると、0から10の数字が順番に表示される。 仮引数numがlimitに到達するまでrecursion()は呼ばれ続ける。 だが、limitの数を大きくすると、途中でエラーになりプログラムが終了してしまう。 function recursion(num, limit){ console.log(num); if(num === limit){ return; }; num++