Book Report: JavaScript Patterns

Before picking up what I actually had on my list to learn this year, and finding myself writing more JavaScript than ever at my current client, I thought it would be wise to take a deep dive into the language, it’s lesser-known features, and it’s best practices. I knew a fair amount, but I was not prepared for what was contained in JavaScript Patterns by Stoyan Stefanov.

The book started with an overview of general best practice patterns in javascript – things like using a cached length in for loops, single var declarations, equality checks, namespacing, and quickly moved to advanced object creation patterns, functional patterns like memoization and currying, and coverage of most of the Gang of Four patterns. At each step along the way, examples and detailed explanations drove individual points home and provide good future reference.

While all of the information in this book is well-written and valuable, much of it is good in theory but probably wouldn’t see the light of day in most projects (Module pattern, Constructor patterns, Inheritance strategies), unless you are not using an existing framework or are rolling your own. It is very valuable to learn how things operate behind the scenes, and some of these patterns are now recognizable for me even in the ExtJs source, but I’m not sure I’ll have opportunities to use many of them while writing new code. That said, the items that will see the light of day – implementing best practice patterns, some of the GOF patterns, and explaining scope and other common misconceptions developers have with the language are absolutely critical – good for newbies and good refreshers for veterans. I know tools like JSLint encourage you to leverage most of these practices/patterns, but having a deep understanding of why you should leverage them is even better.

This is next-level JavaScript understanding that I previously did not have. I highly recommend this book, and I recommend keeping it handy if you’re writing JavaScript regularly.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s