Introduction

Computers are everywhere. Desktop computers, laptop computers, tablets, and phones, not to mention all the computers in our cars, toys, and the huge server farms in the 'cloud'.

We control computers by writing computer programs. For most of the computers we encounter, each one was programmed using a different programming language. A program written for an iPhone won't run on an Android phone. A program written for Windows won't run on a Macintosh. A program written for a server in the cloud won't run on my desktop computer. This is because those programs were not written using international standards. But all of those computers do support the same international standards, and we can write one program that will run on all of them if we use standards. The standards that all of these computers support are HTML5, CSS, and Javascript.

All of those computers have web browsers, and all of the web browsers use HTML5, CSS, and Javascript.

Javascript has grown over the years to become a powerful universal programming language. It runs quickly on all of those computers because the browser translates it directly into the language of the machine. It can access the hardware on the machine, such as cameras, lights, radios, buttons, touchscreens, mice, keyboards, accelerometers, compasses, gyroscopes, and much more.

With a web page and some Javascript code, we can control the world.

Throughout this book, we will introduce new ideas, new jargon, and new language features by example, rather than by defining them. People learn when things are repeated in context much faster than by memorizing definitions. The same goes for programming. People learn to program by example. By looking at programs and seeing how they work. Reading a description of a programming language would put you to sleep. But by repeatedly seeing computer code and taking programs apart, changing little things to see what happens, by seeing patterns in code, that is how people actually learn to program in the real world. And that is how we will teach you Javascript.