Before class, read the JavaScript section in chapter 3 of Scott Murray's Interactive Data Visualization for the Web. Don't worry if it moves fast. We will be going over everything dozens times.

JavaScript is a programming language developed in 1995 with the original intention to create client-side (aka browser) interaction. Since then JavaScript has exploded all over the web in a dizzying array of open source libraries and server side applications.

We've already seen the basic data types in JSON. Now let's see how JavaScript works in the console, the command line interface to the browser.

<script>
    console.log("I am psyched!");
</script>

JavaScript programs are placed between HTML script tags. This lets the browser know not to parse the text as HTML but rather as JavaScript. Above is a pretty common debugging function that outputs onto the console.

Variables store data. They are declared using the "var" keyword and assigned a value using the "=" operator:

var foo = 5;
foo = "cheese";

In the example above, foo (a much used example variable) is declared and assigned a number. It is then reassigned a piece of text, otherwise known as a string. Variables can also be true or false or be assigned more complex structures.

You will be introduced to control structures that add logic and iteration to a program — the features that will allow your code to do things that humans cannot. And finally we will write our own functions that access the DOM, or Document Object Model. Along the way we'll discuss scope, dynamic types, concatenation. All these words may seem cryptic at first, but I assure you that the concepts they refer to are easily absorbed.

Homework

Do the last three exercises—Looping Triangle, FizzBuzz, and Chess Board—at the end of chapter 2 in Eloquent Javascript by Marijn Haverbeke.

Recommended

Read the first three chapters of Eloquent Javascript.

Approaching programming for the first time can be daunting. You may find it helpful to review the materials from different sources. Watch section 2 of Lynda's JavaScript Essential Training series and section 6 of Lynda's Introducing the JavaScript Language. Codecademy has a module on JavaScript. If you're a cat lover, check out JS for Cats.