C H A P T E R  9

Writing Better JavaScript

In this chapter, I explain some of the techniques I use to create better JavaScript. This is not a language guide, and I won’t be demonstrating any code hacks or tweaks. My coding preferences are your maintenance nightmares, and vice versa. I have seen otherwise mild-mannered people end up in a screaming match over the “right” way to code, and I don’t see the point in lecturing you when I have a fair few bad habits myself.

Instead, I am going to show you some of the techniques I use to make my code easier for other programmers and projects to use. Most large-scale web apps have a team of programmers, and sharing code becomes important.

I have been dumping useful functions into the utils.js file throughout ...

Get Pro JavaScript for Web Apps now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.