< MY SKILLS PAGE

Self-Study of

Eloquent JavaScript, 4th ed. (2024)

Textbook by Marijn Haverbeke

Self-study by Nicolas Hernandez

Full textbook made available online by the author

Preamble

This is a self-study effort from January 2025. The scripts I wrote for the chapter exercises are at the bottom of this page's source code.

I've been eying this textbook for a few days now, but since I have this website, I figure this is a good place to host my notes in an environment where I can actually execute JavaScript. I didn't have a place to put it, though, so I added an extra index page to branch my site structure off into a self-development page, where I have the link to this page. It doesn't take long to actually make pages, but because they're my pages, I get to choose to give them novel creative designs, which adds artistic & troubleshooting processes on top of the coding.

All of this just to start studying, not that any of that was necessary. I enjoy the content of the work and the learning involved, if that's not made apparent by the existence of this page. What kind of fool works without being told? One who's curious or creative or otherwise self-driven... that kind of fool! And now, I'll fool around with the content of this book.

Eloquent JavaScript, 4th Edition, by Marijn Haverbeke
This page is themed after the cover of the book.

Chapter 0 - Introduction
"A sense of what a good program looks like is developed with practice, not learned from a list of rules."

This chapter discusses very basic concepts on the what & why of programming & JavaScript, so the part that shines out to me is the above quote. The author isn't teaching from a place of telling you what should be done, but rather from preparing you to tell yourself what should be done.

One who's not an artist doesn't know the rules. A good artist knows the rules well and follows them well. A great artist knows the rules well... and breaks them. Not by simply ignoring them, but by deconstructing the very reasons those rules exist.

The author and I share some values. That's what I've learned from this book's introduction.


Chapter 1 - Values, Types, and Operators
That's not a bug, it's a feature.

This chapter had lots of basic operations, plus the nullish operator ("??"), which browsers didn't even widely support until 2020. I'm not sure a great number of people formally educated until just recently would even know about it if they're not doing occasional reviews of the base technology like I'm doing here. Even then, lots of documentation was made before this was well-supported. It's a case where the latest textbook edition is necessary if it's to supply this knowledge. Sure enough, this feature isn't in the same textbook's previous edition.

These are some concepts from this chapter that I haven't been using in my JavaScript:

Here are some concepts I know that supplement this chapter:

Between these two lists, some of them are maybe not intended by the language, but they're all consistent enough to be used as outright features.


Chapter 2 - Program Structure
The devil's in the details.

I already knew everything that was in this chapter, or at least, I knew everything it intended for me to know. Of the (offhand-mentioned) list of reserved keywords, I haven't been using most of the object-oriented ones in my JavaScript. The keywords async and await are conspicuously missing from the chapter's list of keywords, and I don't think I've ever used the keywords with or yield. None of this is in the intended scope of the chapter, but if I'm brushing up on my JavaScript, I think it's good to look out for places where I can be thorough.

The with keyword is deprecated, but here's my first script using yield. The below elements generate a number between the lower & upper bounds, then stops generating after 10 yields, unless you change the bounds:





[press the button to yield a value from a generator function]

Chapter 2 Exercises


Chapter 3 - Functions
Every instruction is made of smaller instructions, every little bit's got a million bits.

These chapters are getting longer now. There's a little quirk to be found in a chapter that instructs how to write sets of instructions, while part of that instruction is an example specifically about recursion.

The book doesn't specifically endorse one way or the other when it comes to creating functions, but I'm bought in on the arrow functions. I always thought that unless two functions must reference one another, it's bad form to use a function before it's defined in the code. So I didn't use this quirk of function fun() {} declaration notation and wound up forgetting about it. Plus, this notation never lets you define fun as a constant, and I always define functions as const whenever possible. const fun = () => {} is valid JavaScript, and const function fun() {} is not.

I should also note that I'd forgotten about default function inputs that replace undefined ones, where a function is defined (a, b = 'default input') => {} so that if a function call is missing an argument, it can fill b in with the assignment expression in the function arguments definition.

Chapter 3 Exercises


Chapter 4 - Data Structures: Objects and Arrays
This is the longest chapter in the book!

Sure enough, my ability with objects in JavaScript has been pretty under-utilized. In fact, I probably learned things in the wrong order the first time around, because I never use the in or delete keywords, because I didn't understand them when I first learned about them, because I wasn't using JavaScript objects until later on! So here's another list of things I haven't been using in my JavaScript:

In spite of the increasing verbosity of the chapters, I know some things would remain a complete mystery for an actual beginner reading this book. In the "Destructuring" section, it says you can use square brackets to "look inside" of an array value to bind its contents, but it doesn't give an example, making this a nearly indecipherable remark if you don't see an example (let [a, b, c, d] = someArrayWith4Elements).

The chapter had a bit of math, too, which is cool. It sometimes takes lots of math & working out general formulas to make my scripts act the way I want them to, so seeing someone else using math as part of their process is refreshing. That's surprisingly uncommon for what programming fundamentally is.

Chapter 4 Exercises


Chapter 5 - Higher-order Functions
Yo, dawg, I heard you like functions.

Well, I looked ahead and saw that chaper 4 was the longest chapter in the entire book. This chapter was significantly shorter, though it also covers inbuilt language specifics that are wheels I've tended to reinvent rather than using their implementations that are available by default. Hopefully by having run by these here, I'll have better recall when it comes time to use them:

Chapter 5 Exercises


Chapter 6 - The Secret Life of Objects
It's short for "classification."

There's something so arcane about the Symbol type. When a Symbol is instantiated, I imagine a unique glyph appearing and being used as the label for whatever property it corresponds to.

This chapter had more tinkering with objects, so here are some more concepts I haven't been using in my code:

I already knew about maps, the "extends" & "static" & "super" keywords work like in Java. The syntax is similar, but you can tell that all things about JavaScript classes are syntactic construct made by composing objects & functions such that they can look & act like Java classes, with the syntax hiding all of the complexity required for that underneath. It's not a fundamental of the language like it is in Java; it's a bunch of other concepts all coming together to make this, which makes it harder to wrap your head around, despite the code itself being mostly familiar.

Chapter 6 Exercises


Chapter 7 - Project: A Robot
Go, RoboJackets!

--

Chapter 7 Exercises


Chapter 8 - Bugs and Errors

--

Chapter 8 Exercises


Chapter 9 - Regular Expressions

--

Chapter 9 Exercises


Chapter 10 - Modules

--

Chapter 10 Exercises


Chapter 11 - Asynchronous Programming

--

Chapter 11 Exercises


Chapter 12 - Project: A Programming Language

--

Chapter 12 Exercises


Chapter 13 - JavaScript and the Browser

--

Chapter 13 Exercises


Chapter 14 - The Document Object Model

--

Chapter 14 Exercises


Chapter 15 - Handling Events

--

Chapter 15 Exercises


Chapter 16 - Project: A Platform Game

--

Chapter 16 Exercises


Chapter 17 - Drawing on Canvas

--

Chapter 17 Exercises


Chapter 18 - HTTP and Forms

--

Chapter 18 Exercises


Chapter 19 - Project: A Pixel Art Editor

--

Chapter 19 Exercises


Chapter 20 - Node.js

--

Chapter 20 Exercises


Chapter 21 - Project: Skill-Sharing Website

--

Chapter 21 Exercises


Reflection

--

Chapter 4 Exercises