Introduction

What Do You Mean, "Web Savvy?"

If you have written HTML and CSS, but JavaScript has always scared you a little, this book is for you.

If you know enough to put some jQuery plugins on a page, but not enough to fix them when something goes wrong, this book is for you.

And if you have learned JavaScript in a casual way, but you're intimidated by the sudden outpouring of technologies around it--Node.js! Backbone! Grunt!--and want to understand it in a more disciplined fashion, this book is for you.

Teaching at Seattle Central Community College, many of my students have a little bit of web experience, but they're not programmers. Maybe they call themselves "web designers," and their experience has been mostly in HTML and CSS, or they're on the development track but they've never done any real coding before. Either way, they (and, I believe, a large number of other interested would-be students) are ill-served by the vast majority of JavaScript books, which are either long on theory and short on practical context, or are aimed at more experienced programmers.

This book aims to address that audience. If you know your way around a <body> tag but you've never written your own JavaScript from scratch, you can be considered "web-savvy": you've got the background, you just need some guidance and a helping hand. I'm writing this book for my class of developers and designers, but I hope you'll find it useful as well.

What This Book Will Teach You

What This Book Won't Teach You

Crucially, this book is not a comprehensive guide to JavaScript and jQuery. One of the most important skills you'll need as a programmer is the ability to read and absorb technical documentation, such a the Mozilla Developer Network or the jQuery API docs. It's always better to use those first-hand sources for information, rather than relying on a paraphrase that might be out of date, since the technology of the web moves very quickly.

That said, there's plenty of misinformation out there on the web. So throughout the book, you'll find plenty of links to articles, documentation, and further reading to fill in the gaps. There are also intermittent chapters ("intermissions") that cover topics outside of strict JavaScript coding, such as source control, project architecture, and good HTML best practices. Finally, at the end, I'll recommend some resources that can guide you as you continue forward on your JavaScript career.

Why JavaScript?

Since it was invented in 1995, JavaScript has undergone a transformation that's been nothing short of astonishing. Originally conceived as a simple way to add simple interactions to web pages, it has since powered the shift toward web applications that can rival desktop programs. With the introduction of Node.js, it has spawned a remarkable new set of development tools and processes on the desktop. And it has introduced millions of new coders to techniques like closures and functional programming.

I'm not sure that JavaScript is a good language--it has a collection of serious flaws, many of which date back to its hasty creation--but I do think it's a fun language. JavaScript can be expressive, even whimsical. It doesn't hurt that it's possibly the best cross-platform programming language ever created, since wherever there is a web browser, you'll find JavaScript. And in an increasingly web-powered world, we find browsers everywhere: in your phone, on your TV, and embedded in many of your favorite non-web applications (the company where I work, ArenaNet, uses a version of Google's Chrome to power many of its in-game interfaces for its flagship title, Guild Wars 2). You can build serious software in JavaScript, and many people are doing so.

I also believe JavaScript provides us with a unique opportunity. Like the BASIC code I played with as a kid, JavaScript puts the ability to program right at your fingertips, for free, and without any gatekeepers or restrictions. On the web, you can write whatever software you want, without worries about cost of entry or being censored from an app store. As our world is powered more and more by code, that's a deeply-important freedom to have. Learning to write for the open web platform has been one of the most fulfilling and useful skills I've ever learned. I hope, by the end of this book, you'll agree.

About Me

Like a lot of web developers, I'm not formally trained in computer science. I was originally a journalist in Washington, DC, where I ran the multimedia team at Congressional Quarterly, using JavaScript and other languages to help the newsroom report on politics and government. In 2011, I moved to Seattle, where data journalism jobs are thin on the ground, and transitioned into doing straight-up web development for a living. You can see examples of my work, from writing to data visualization to software, at ThomasWilburn.net.