Categories:
Partners

"Pro JavaScript Techniques" Book review

Book review by JavaScriptKit.com | Publisher: Apress, John Resiq, 1st edition (Dec 11th, 2006) | Reviewed on: March 26th, 07'

I recently had the chance to read over "Pro JavaScript Techniques," part of the new wave of JavaScript books that approach JavaScript as a modern, mature programming language. The book is written by John Resiq, certainly no stranger to the JavaScript community, as the author of the well known JQuery library. "Pro JavaScript Techniques" is a slim book, at around 350 pages. Before continuing, here's the TOC for the book:

CHAPTER 1 - Modern JavaScript Programming
CHAPTER 2 - Object-Oriented JavaScript
CHAPTER 3 - Creating Reusable Code
CHAPTER 4 - Tools for Debugging and Testing
CHAPTER 5 - The Document Object Model
CHAPTER 6 - Events
CHAPTER 7 - JavaScript and CSS
CHAPTER 8 - Improving Forms
CHAPTER 9 - Building an Image Gallery
CHAPTER 10 - Introduction to Ajax
CHAPTER 11 - Enhancing Blogs with Ajax
CHAPTER 12 - Autocomplete Search
CHAPTER 13 - An Ajax Wiki
CHAPTER 14 - Where Is JavaScript Going?
APPENDIX A - DOM Reference
APPENDIX B - Events Reference
APPENDIX C - The Browsers

The first chapter lays the foundation for the rest of the book, by defining just what "modern" JavaScript Programming implies, from Object Oriented Programming to the use of the DOM and CSS to separate code from content on a page. For people confused about this terminology, it offers a nice crash course.

Chapters two and three discuss arguably the crux of modern JavaScript coding- OOP and creating reusable code. These two chapters fell a bit short of my expectations. While all the important concepts of OOP were covered, from objects, classes, to private/public members and closures etc, the examples used were all very abstract, leaving readers hovering, looking for a practical example on which to land on. The very powerful concept of inheritance was explained in a haphazard way that probably will leave quite a few people scratching their heads (for an excellent explanation on inheritance, I recommend "Professional JavaScript for Web Developers" Chapter 4). The author wraps up Chapter 3 by overviewing some of the most popular JavaScript libraries currently out there, such as Prototype and Dojo, while also discussing techniques for effectively packaging your own code for usability and efficiency.

Chapter five and onwards is where the book really shines, at least for me. Like traversing a document tree, John methodically looks at all the common challenges faced by the modern JavaScript programmer, and presents solutions in bite size portions that like Lego pieces are very much self contained yet together form larger solution blocks. In Chapter 5, "The Document Object Model", John shows you powerful techniques for accessing nodes of the document DOM generically, by creating your own arsenal of useful routines. You learn, for example, how to handle white space in the DOM, access node based on their relationship to others etc. The techniques are generally small, clever, and all purpose in nature. In Chapter 6, readers are reintroduced to Events in the DOM, an often confusing topic to JavaScript programmers. I found this chapter adequate, though it would have been nice to cover more advanced event behaviours commonly required in DHTML, such as detecting when the mouse has moved out of the parent container of a child element (for DHTML menus) etc. Still, this chapter provides enough insight for people who are using event handling in JavaScript without knowing exactly how it operates. Chapter 7 is invaluable in helping you implement sleek visual effects and animations on your page through the merging between CSS and JavaScript. Crucial techniques are covered, from how to access global CSS values in JavaScript, determining the dimensions of elements, to finding out the position of an element relative to the document. Instead of just showing you a massive (and massively waste of space) script, John provides you with the all the essential tools you need to create common visual effects. What's that saying "Teach a man to fish, and..." Ah I forget.

And as is almost mandatory in programming books these days, the later chapters of this book consist of case studies of a few practical JavaScript applications, with step by step walk thru of them from concept to form. Usually I'm not a fan of case studies (too much reading for too little yield), but you learn just as much by examining John's elegant code and coding style as you do with the end result. So these chapters are engaging regardless of where you're coming from.

The final chapter provides an interesting read on the apparently not-do-distant future of JavaScript, such as new array features in JavaScript 1.6, enhanced support for scoping in JavaScript 1.7 etc. And finally, the Appendixes provide stripped down references on the DOM and the Event Object in JavaScript. They're certainly not meant to displace O'Reilly's JavaScript/ DOM The Definitive Guide References, but still useful in their own right.

I'd definitely recommend this book for its intended audience of intermediate to advanced JavaScript programmers. It's choke full of techniques that are useful on their own or collectively, each one building on the next. Apart from the deficiencies mentioned in a couple of chapters (plus a few errors in the examples that will frustrate you), this is an inspiring book for the professional JavaScript programmer;

Our rating: 8/10