JavaScript

core concepts

[Netscape, 1995] displayed Web pages that were not very lively. You could have a nice cartoon of a monkey on the Web page, but there was no way to make the monkey dance when you moved over it with your mouse. Figuring out how to make that happen was the job of a language developer named Brendan Eich. He sat down and in a few weeks created a language called JavaScript [...] as browsers proliferated and the Web grew from a document-delivery platform into a software-delivery platform, JavaScript became, arguably, the most widely deployed language runtime in the world. If you wrote some JavaScript code, you could run it wherever the Web was—everywhere.

Paul Ford, from What Is Code in Bloomberg Business (2015)


There are loads of different programming languages out there, but they all basically do the same thing: allow you to write programs that get the computer to do what you want it to do. All programming languages contain the same core concepts (variables, functions, loops, conditional statements, etc) but they all have slightly different ways of expressing these concepts, which is to say, they all have different syntax and APIs. Although any solid programming language could be used for anything (whether you're creating a website, or an iPhone app, or a video game, or a robot) some languages have special features that make them better suited for certain contexts or tasks. Different languages also have different communities of developers writing libraries and frameworks for that language.

Although JavaScript is not the only programming language we can use on the Internet, it's definitely the most popular, which means there's a large community creating libraries, tutorials and answering questions online. Furthermore, although JavaScript can be used for everything from controlling robots to scripting PhotoShop, it was originally invented as a programming language for the Web specifically, and so it's obviously the natural choice for us.

Below you'll find a handful of netnet examples demonstrating the core programming concepts expressed in JavaScript...





the ingredients

If algorithms are like recipes, the data we store within variables are the ingredients

declaring variables
reassigning variables
simple data types
data structures: Arrays
data structures: Objects

the instructions

conditional statements, functions (sometimes called methods or routines) and loops are how we "control the flow" of the instructions that make up our algorithmic recipes

conditionals (if, else)
functions (aka methods)
loops (for, while)