Member-only story
An Intro to Javascript for Experienced Programmers Who Could Use a Strong Dose of Fundamentals

When we were getting ready to launch Better Programming, I reached out to someone I consider a master of programming, Reginald Braithwaite (known as Raganwald in many quarters). What I wanted to know is if he’d contribute a sample chapter from his book JavaScript Allongé, the “Six” Edition (amazon | leanpub).
His reaction, instead, was simply to change the copyright terms on his book to Creative Commons: Attribution/Share-alike and tell me to run wild with it. (Maybe wild is an overstatement.)
So below is a section of the book, a very long section, that I found valuable in a very particular way. There are lots of JavaScript tutorials for people who’ve never programmed before. But I’ve programmed forever, at least since 1994 (or even the ’80s, if you count moving an on-screen turtle with Logo).
However, when the programming world jumped to JavaScript, I got a little lost. It took me a while to realize why, although it’s obvious in hindsight. I never really understood the fundamentals of the JavaScript language. I’d previously always had the experience of languages being similar enough that I was mostly just looking up the occasional syntax detail. For example, I shipped my first PHP and Rails projects with a mental model that was based on Perl web development. JavaScript was just a bit too different though, and so I find myself needing to go back and study the fundamentals.
That’s where Reginald’s book comes in. I find his writing to be pedantic in ways that remind me of my computer science professors. And that’s exactly what I’m looking for — this isn’t a tutorial for first-time programmers. Plus, I imagine that Reginald would say that having pedantically detailed knowledge of your programming languages is pragmatic — you’ll work faster and make fewer mistakes.
The tutorial below does start with the extreme basics: values and then variables. I found it valuable to get that refresher. But the real meat came when he gets into functions.
I read the below in Chrome with my JavaScript console on like so. That way I could test my own versions of the code as I went.