Preface
A couple of years ago, JavaScript was generally looked down on as something that one did when one couldn’t be bothered doing proper programming. The advent of Ajax has given the language a smart new set of clothes, and it’s almost respectable to describe oneself as a JavaScript programmer. I’ve followed this transition myself, from doing JavaScript here and there because I had to, to figuring out some fairly neat tricks that just couldn’t be accomplished any other way.
I even started to dig into the language itself, and was pleasantly surprised to find out that, although it wasn’t really that much like Java at all, it had a style and logic of its own. I got my head around prototype chains and started writing JavaScript objects. I was very pleased with myself the day I figured out how closures worked in JavaScript, and congratulated myself on achieving a certain level of mastery. Pride comes before the fall.
I picked up Sam Stephenson’s Prototype library somewhere along the way, and copied a few lines of code written by someone else who had used it, and found that it provided shortcuts that speeded up my typing. It wasn’t long before curiosity got the better of me and I wanted to know how it worked. When I first read the source code for Prototype, I thought I’d stumbled across some arcane dialect of Perl. This didn’t look like the JavaScript that I was accustomed to writing, and I did the only thing a brave and seasoned programmer could do—I ran away and hid.