resource / Front-End-Standards

Front-end development standards for Resource.
MIT License
23 stars 1 forks source link

Remove Array.join() string contatenation standard #27

Closed Krxtopher closed 11 years ago

Krxtopher commented 11 years ago

I think the guideline to use Array.join for string concatenation should be removed. I know performance is sighted as the reason, but this smells of premature optimization to me. In real world use cases, the performance difference is insignificant.

For example, on my machine (in Chrome), concatenating 1000 items is so fast with both methods (traditional concat and Array.join()) that it is unmeasurable (< .5 msec). Even at 10,000 items the traditional concat only takes just 1-2 msec which is an insigificant amount of time.

Array.join() and traditional concatenation with "+" should both be acceptable in our standards. The method chosen in any given situation should be the method that conveys the code's intent most clearly to the reader.

(BTW, I'll double-check performance on IE as soon as I can, but I'm guessing the outcome for real-world use cases will be similar)