From Eloquent Javascript Chapter 2