Eloquent JavaScript, 3rd Edition

Eloquent JavaScript, 3rd Edition

A Modern Introduction to Programming
by Marijn Haverbeke
December 2018, 472 pp.

Download Chapter 5: Higher-Order Functions

JavaScript lies at the heart of almost every modern web application, from social apps like Twitter to browser-based game frameworks like Phaser and Babylon. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.

This much anticipated and thoroughly revised third edition of Eloquent JavaScript dives deep into the JavaScript language to show you how to write beautiful, effective code. It has been updated to reflect the current state of JavaScript and web browsers and includes brand-new material on features like class notation, arrow functions, iterators, async functions, template strings, and block scope. A host of new exercises have also been added to test your skills and keep you on track.

As with previous editions, Haverbeke continues to teach through extensive examples and immerses you in code from the start, while exercises and full-chapter projects give you hands-on experience with writing your own programs. You start by learning the basic structure of the JavaScript language as well as control structures, functions, and data structures to help you write basic programs. Then you’ll learn about error handling and bug fixing, modularity, and asynchronous programming before moving on to web browsers and how JavaScript is used to program them. As you build projects such as an artificial life simulation, a simple programming language, and a paint program, you’ll learn how to:

  • Understand the essential elements of programming, including syntax, control, and data
  • Organize and clarify your code with object-oriented and functional programming techniques
  • Script the browser and make basic web applications
  • Use the DOM effectively to interact with browsers
  • Harness Node.js to build servers and utilities

Isn’t it time you became fluent in the language of the Web?

All source code is available online in an interactive sandbox, where you can edit the code, run it, and see its output instantly.

Author Bio 

Marijn Haverbeke is a programming language enthusiast and polyglot. He's worked on a wide range of software systems, from databases to compilers to editors. He runs a small business around his open source projects.

Table of contents 


Part I: Language

Chapter 1: Values, Types, and Operators
Chapter 2: Program Structure
Chapter 3: Functions
Chapter 4: Data Structures: Objects and Arrays
Chapter 5: Higher-Order Functions
Chapter 6: The Secret Life of Objects
Chapter 7: Project: A Robot
Chapter 8: Bugs and Errors
Chapter 9: Regular Expressions
Chapter 10: Modules
Chapter 11: Asynchronous Programming
Chapter 12: Project: A Programming Language

Part II: Browser

Chapter 13: JavaScript and the Browser
Chapter 14: The Document Object Model
Chapter 15: Handling Events
Chapter 16: Project: A Platform Game
Chapter 17: Drawing on Canvas
Chapter 18: HTTP and Forms
Chapter 19: Project: A Pixel Art Editor

Part III: Node

Chapter 20: Node.js
Chapter 21: Project: Skill-Sharing Website
Chapter 22: JavaScript and Performance

Exercise Hints

View the detailed Table of Contents
View the Index


“Eloquent Javascript 3rd edition is a worthy and much-needed update to the popular programming book. The fact that the book covers ES6 is worth a re-read, but the new edition goes above and beyond with new illustrations, a new exercise, and tighter writing. The 3rd edition of the book is substantially improved from its predecessors and worthy of the hype.” br>
Books on Code


A full list of errata is also available at http://eloquentjavascript.net/errata.html

Page 111: In the second paragraph below the example code, instead of "content method”, the text should say “element function.”

Page 134: In the third paragraph of the section, a function "promptInteger" is referred to. The function is actually called "promptNumber", and the word “whole” should be dropped from the sentence (it accepts non-whole numbers, too).

Page 231: code lines that read:
for (let i = 0; i < node.childNodes.length; i++) {
if (talksAbout(node.childNodes[i], string)) {

should be:
for (let child of node.childNodes) {
if (talksAbout(child, string)) {

Page 234: In the code, “edition” is misspelled as “editon.”

Page 336: property `fillColor` should be `fillStyle` instead

Page 285: The text refers to the "arrow" binding, where it should say "arrowKeys."