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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.