3 ms·
For recursion vs. looping, it really depends on what you're doing. In my js experience though, most of the time looping is either faster or equal to recursion,
by annon 16y ago
For recursion vs. looping, it really depends on what you're doing. In my js experience though, most of the time looping is either faster or equal to recursion, while being significantly easier to understand at a quick glance.
In this case, the loop will outperform recursion because of all of the slice calls in the recursive version.