Ziff-Davis Enterprise 
DevSource: Microsoft Developer Resource
Add OnsArchitectureLanguagesTechniquesUsing VSForums
 
Home arrow Languages arrow Book review: Head First JavaScript by Michael Morrison
Book review: Head First JavaScript by Michael Morrison
By Lynn Greiner

Rate This Article:
Add This Article To:

Head First JavaScript, by Michael Morrison. O'Reilly, December 2007. $39.99 ISBN: 0-596-52774-8. 

When the first words you see after the name of the book on the title page of a programming manual are "Wouldn't it be dreamy…", it's easy for you to think that this is not a volume for the Serious Programmer.

ADVERTISEMENT

You'd be thinking wrong.

O'Reilly's Head First JavaScript is a book for the serious programmer who wants to have a little fun while taking on a new, and, thanks to Ajax, significant language.

The Head First series uses a playful, highly visual teaching method that, it explains, keeps the brain engaged and makes it easier to absorb the material. According to Head First Web page (http://www.headfirstlabs.com/readme.php), the human brain craves novelty, and pays attention to significant events like, say, the sight of a prowling tiger. Since said tiger may be hunting for a snack, and you're a tasty morsel, you tend to look for a handy exit when you see it.

On the other hand, when you're in a safe environment trying to stagger through a dull tome that your boss or teacher thinks is important, your brain tries to filter out the mundane so it can monitor for threats like hungry tigers or cranky roommates.

Head First books are designed to be anything but mundane! They're full of whimsical images and multiple fonts and puzzles and quizzes that, says O'Reilly, make your brain sit up and take notice despite the tiger-free environment.

Head First JavaScript begins (after an introduction to its teaching methods) by showing you where JavaScript fits into the grand scheme of things, and then inviting you to deduce what the JavaScript portions of a simple Web page are doing, in an exercise called "Sharpen Your Pencil". These exercises are included throughout the book, with annotated solutions on the following page, so you can reinforce what you've learned so far.

But, since everyone learns differently, the book also includes quizzes, crossword puzzles, fill-in-the-blanks exercises set up as though the answers are on fridge magnets, and, of course, plenty of sample code to play with.

Author Michael Morrison begins with a problem – your boss has invented a virtual pet called iRock, and needs you to make it interactive. Through a series of iterative changes, you learn the basics of moving from a static Web page to an iRock that greets people, remembers who they are, and turns moody if it doesn't get enough attention.

In the process, you're introduced to events and handlers, alerts, functions and variables. Oh, yes, and cookies and timers.

When the basic iRock is working, you segue to helping debug a donut shop's flaky online ordering system, learning about forms and data types and math. Decisions (if/else and switch/case) are taught as you work on an adventure game, and the ins and outs of arrays come courtesy of an application that allows users to select theatre seats.

And so it goes. Each chapter builds on the previous, introducing programming techniques and showing how a working page can be improved. For example, in the beginning you're coding within an HTML page, but are quickly taught why it is a Good Thing to separate HTML and script code, and how to do it.

Around the middle of chapter 8, just when you're getting comfy, in pops the DOM (document object model), and you're shown how it replaces things like innerHTML, and why, and you're introduced to object-oriented scripting.

Much of the rest of the book is devoted to building a program for creating and displaying blog entries, which finally leads to a few pages on server-side operations using PHP.

All this is shown as much as told. You can download all of the programs from the book's Web site (http://www.headfirstlabs.com/books/hfjs/), along with a sample chapter to give you a taste before you cough up your $40. There's also a practice page where you can enter and run JavaScript in a safe environment.

You do need to have a basic grasp of HTML and the mechanics of Web pages to get much out of this book, but you don't need to know anything about scripting. You don't even have to know much about programming, although if you do, you'll still pick up some hints. Morrison even shows how to use the debugging features in the various browsers to track down glitches (Firefox is, at the moment, the most developer-friendly, he says).

There's an online forum for reader questions, and Morrison is extremely active in it. He's even fessed up to the odd "oops" in the first printing (often pointed out by eagle-eyed readers), and provided corrections and elaboration.

This book is not for someone who's looking for a comprehensive JavaScript reference (there's a book with a rhino on the cover that handles that nicely). It just contains the snippets you need for the tasks at hand; there's a "where do we go from here" page of suggested references at the end. It's a book for someone who'd like to learn enough JavaScript to get to the point where something like the rhino book could be useful, and to have some fun doing so.




Discuss Book review: Head First JavaScript by Michael Morrison
 
>>> Be the FIRST to comment on this article!
 

 
 
>>> More Languages Articles          >>> More By Lynn Greiner
 



DevSource video
Devsource Video Series
Manipulating Society through Technology
Jeremy Bailenson, Director of the Virtual Human Interaction Lab at Stanford University, talks about virtual reality, avatars, Moore's law, how real world behaviors influence online reality, and societal manipulation through technology!
>> Play video
>> Read article
>> See all videos
DevLife Blog
Julia shows you some wicked cool use of LINQ!
MSDev Blog
Is the latest Delphi product, RAD Studio 2007, really necessary?
Make it Work
.NET makes runtime type checking a breeze. See what Peter has to say about it in this week's tips!
News
Microsoft Counts on App Support for Vista
Microsoft has taken pains to demonstrate that Windows Vista will have ample application support.
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.