Book Review: Secrets of the JavaScript Ninja

When I received a copy of Secrets of a JavaScript Ninja for my birthday, I was understandably excited. As a long-time user of the jQuery, I have a great deal of respect for John Resig, who is the lead developer and creator of the useful and popular library. It should be noted that this is not a book about jQuery. This is a book about advanced JavaScript fundamentals.

By the time I read Secrets of the JavaScript Ninja, the playing-field for browsers and had changed a little bit. For example, Resig only mentioned IE6, 7, 8 and 9. IE10 had obviously not been released at the time of the writing. That, of course, is the unfortunate thing about writing books on technology. As soon as a book is published, the technology has already advanced.

<img src=“/images/blog/secretsofthejavascriptninja.jpg“ style=“float: left; margin-right: 15px; margin-bottom: 15px;“ />

By the second chapter, we were introduced to unit testing JavaScript code. The interesting thing about the unit testing chapter is that it was literally foundational for the entire book. Everything that is taught in the book from that point on is proven and asserted through a custom unit test interface written in the second chapter.

From there, we delve into understanding some of the foundations of the JavaScript language such as functions, objects, timers, and regular expressions. While these topics may seem juvenile, they were presented in a very clear and concise manner and I definitely felt like I learned some helpful tricks to optimize my code.

The next section was on more advanced topics. There was a chapter on runtime code evaluation that I thought was really interesting. It compared various ways to pull in new code and execute it at runtime. There was actually an entire chapter on the “with“ statement. It was not a defense of the controversial statement, but more of a primer on how to interact with it in existing legacy codebases. The section closed with an introduction to dealing with cross-browser issues without resorting to browser sniffing techniques.

The final section of the book covered DOM events, working with DOM elements and CSS selector engines. All of the topics were covered with browser nuances in mind.

In short, this book was not a book about how to use jQuery, but someone could easily walk away from reading it with the knowledge to create their own jQuery-like library. The techniques employed in Secrets of the JavaScript Ninja could easily be used in any JavaScript development, whether you are building a library or just an application. It has probably been the single most helpful JavaScript book I have read.

comments powered by Disqus