Intro and JavaScript
Lecture slides and code
You can get the slides here. The slides refer to some JavaScript files, provided below. You can also play with this code in your browser here and here.
Recommended reading
If you have not worked with JavaScript before, take some time to familiarize yourself with the basics of the language, as most of the labs in this class will be in JavaScript.
We recommend the Mozilla Developer Network’s JavaScript Guide, but there are many other tutorials on the Internet.
Dave Herman’s Effective JavaScript is very good reference that covers a lot of the JavaScript intricacies. You will not this for the class, but if you end up writing JavaScript code in the outside world, this book is must-read.
Additional resources/reading for the curious
- Block
bindings
and the difference between
var,let, andconst. - Why a language like JavaScript took over the world? Not that uncommon, see The Rise of “Worse is Better”.
- Closures explained; see, especially the creating closures in a loop section.
- Private properties in (modern) JavaScript; we will revisit the idea of private properties (encapsulation) later in the course.
- Short intro to memory management for JavaScript
- ES6 In Depth contains more information on the more recent features introduced to JavaScript.
- Arrow functions.
Source files we used in class
Code illustrating how to implement block scoping with functions:
Code illustrating the use of callback to perform synchronous and asynchronous filesystem reads:
Code illustrating the use of high order functions and closures:
Code illustrating the use of functions to implement modules:
Code illustrating the use of arrow function syntax for function expressions:
Code illustrating simple methods and constructors for JavaScript: