Earlier this week I finished reading JavaScript Patterns, written by Stoyan Stefanov. After I very much enjoyed reading his previous book titled Object-Oriented JavaScript last summer, I instantly bought JavaScript Patterns when it came out and put it on my priority reading list. While Object-Oriented JavaScript is more an introduction to the JavaScript language and targeted towards folks that are either new to the language or already been using it superficially for some time, JavaScript Patterns wonderfully succeeds at building on existing knowledge and taking it to the next level.
This book might as well have been titled “The JavaScript Way”. It’s only 200 pages, but literally packed with great concepts and knowledge about JavaScript and is very dense. While reading this book you can easily notice that the author has an immense amount of experience with JavaScript combined with great writing skills.
The book not only taught me about JavaScript programming. It also challenged the way how I code in other programming languages as well. It made me think about the differences between static and dynamic languages as well as programming languages that have lots of features compared to others that have a more compact feature set but seem to thrive because of their conciseness.
The book has eight chapters. After a short introductory chapter, the author dives right in by laying out a wide amount of JavaScript essentials in the second chapter.
The third chapter discusses Object/Array literals and constructors while the fourth chapter provides in-depth information about functions in JavaScript.
Chapter five and six are real masterpieces. The fifth chapter is dedicated to object creation patterns, explaining private properties and methods, the module and sandbox patterns and much more. Chapter six discusses several ‘classical’ patterns (as in class), ways to accomplish inheritance in JavaScript, mixins, etc. This chapter is also a nice follow-up on chapter six in Object-Oriented JavaScript. These two chapters were real eye openers for me.
Chapter seven provides JavaScript implementations for the Gang of Four patterns, like the singleton, factory, decorator, strategy, mediator, observer amongst others.
Chapter eight is all about programming JavaScript in the browser and manipulating the DOM. I personally found this to be very interesting and good to know, but not that useful. You don’t have to deal with these things anymore as libraries like jQuery are taking care of that stuff for you. Off course, this doesn’t change my view and perception of the entire book. The parts on deploying JavaScript files and the discussion on loading strategies definitely make up for it.
Summarized, this book is AWESOME and is now part of my list of favorite books. I can only encourage you to pick up this book. It’s definitely not a book for beginners, but if you want to take your existing JavaScript skills to the next level and beyond, then reading this book is highly recommended.