bendc / frontend-guidelines

Some HTML, CSS and JS best practices.
8.29k stars 653 forks source link

Recursion in JS is actually bad #721

Closed pbrinkmeier closed 9 years ago

pbrinkmeier commented 9 years ago

As Javascript doesn't have TCO (yet), recursion will make the browser crash when traversing big Arrays. If you cannot be completely sure the Arrays won't be too big, you should avoid it whenever possible.

bendc commented 9 years ago

Pretty much all the examples in the JS guidelines contain at least one feature not supported by one browser. Tail call optimization is one of them.

As mentioned in other issues, this document doesn't take current browser support into account. Eventually, all browsers will implement all these features. These guidelines are based on specs, not on the always-evolving browser landscape.

pbrinkmeier commented 9 years ago

Thanks for the enlightment! I didn't know that :+1: