4 ms·
JavaScript: Bad Practices
- nostrademons 17y agoIt's funny, Google search does almost all of these bad practices, and for good reason. I think that as general principles, most of these are pretty good. What I don't like about the article is that most of these seem to be cribbed off Crockford's presentations, and I'm not sure the author understands why they are good practices or when to break the rules. He also seems to lack an understanding of perspective: yes, counting downwards or manually CSE-ing expressions can save you a few cycles, but even with (pre-Chrome, FF3.5) JS being roughly 1000 times slower than C, the CPU consumption of your JS will still probably be dwarfed by its download time. Optimize for byte-size, not execution time, unless you're doing something like a JS game. He also forgets the most important JS bad practice I know of: don't muck with the prototypes of built-in objects! Just say no: it makes it virtually impossible to build compatible libraries off of your work and version them in a sane way.