found drama

get oblique

review: Data Structures and Algorithms with JavaScript

by Rob Friesel

Data Structures and Algorithms with JavaScriptMike McMillan’s Data Structures and Algorithms with JavaScript (O’Reilly, 2014) uses JavaScript as a vehicle for introducing a number of fundamental computer science concepts. It reminds me a little bit of Tom Stuart’s Understanding Computation[1] — that is, it’s a book about CS topics that targets people without a CS background. One might consider both books to be a gentle introduction to computer science, or “computer science for the layperson”.[2]

At a high level, McMillan walks us through some of these different data structures (e.g., sets, binary trees) and algorithms (binary search, quick sort). These are topics that we might have encountered in introductory computer science courses[3] — he just happens to have chosen JavaScript as the illustrative language here. And there are some good reasons for choosing JavaScript: it is fairly ubiquitous, and it’s comparatively easy to start programming with JavaScript as opposed to many other languages. There’s also this latent assertion that there are many people who are doing professional software development (with JavaScript) who otherwise do not have CS backgrounds.[4]

To this point, McMillan is largely successful. He is able to demonstrate how to implement these data structures and algorithms using JavaScript, even if it isn’t always clear why we would use JavaScript. He clearly articulates the traditional use-cases for each of the data structures and algorithms, but sometimes we’re left wondering why JavaScript? with respect to solving a particular problem (e.g., as opposed to a language that already has that data structure built in[5]). Also, some of his implementations appear to duplicate built-in objects (e.g., his HashMap arguably overlaps with JavaScript’s built-in Object) or else they’re implemented… strangely? (E.g., his Dictionary implementation uses an Array under the hood for no good reason.[6])

That being said, McMillan does a great job of explaining each data structure, what shape they are, why you would want to use one over another, and how they align with certain types of problems. (Same goes for his discussion of search and sort algorithms.) However, despite how strong these discussions are, it also seems to go against the current trend in JavaScript development. As I read through many of these chapters, I thought to myself: “Wouldn’t you just use a function for that?” Granted, the OO approach gives us those functions (as methods) just beneath the façade of the object itself — but still, those thoughts were there: Wouldn’t you just use a function? and Why do this in JavaScript when there are other languages that have first-class support for this?

Overall, I enjoyed McMillan’s book. I found it was a good introductory level instructional text for some of these CS concepts (even if the choice of JavaScript is a bit of a novelty) — but I wouldn’t consider it a practical manual of what to do “in the field”. If you’re doing software development in JavaScript and you’re trying to fill in the gaps of your computer science background, I would recommend this.

Disclosure: I received an electronic copy of this book from the publisher in exchange for writing this review.

  1. I reviewed Understanding Computation last year. It was the first book that helped me to really understand the differences between “computer science” and “software engineering”. []
  2. As condescending as it sounds, there were a couple of times where I thought a good subtitle for it might have been something like “A Field Guide to Real World Computer Science”. []
  3. …had we made it all the way through our introductory computer science courses. Which… you know… I didn’t. []
  4. Long-time readers of this blog will notice the restraint I’m using here by not invoking what I’ve come to think of as “Miraglia’s Assertion”. Or at least resisting the urge to put that in the main body text. []
  5. I deal with sets fairly often in my work and say what you will about Groovy but at least I don’t have to monkey-patch in support for sets. []
  6. He says something in the text about using an Array because we want to output the Dictionary keys in alphabetical order, but then he winds up using Object.keys for that anyway and I just frowned and scratched my head a whole bunch there. []

About Rob Friesel

Software engineer by day, science fiction writer by night. Author of The PhantomJS Cookbook and a short story in Please Do Not Remove. View all posts by Rob Friesel →

2 Responses to review: Data Structures and Algorithms with JavaScript

Cody Carlson says:


Thank you for the review! I just read a taster — and, while I appreciate having the resource of a much-needed algorithms book in JavaScript, I felt some things we left unexplained in the book (WHY does the .next() function iterate the way it does???!!!).

I am versed in algorithms in general at a novice level, but I wanted to see a sort of ‘Industry Standard’ way of applying these algorithms in JavaScript — as it is my primary-language.

I actually found this book very useful in that: knowing a solid pattern for the industry-standard way is helpful — AND — that, as an Application Architect & Sr. Engineer, I find it useful to utilize Software Design Patterns and Data Structures & Algorithms to facilitate consistency as the software scales — especially, as with JavaScript it is up to the developer (not intrinsic to the language) to enforce consistency.

My only questions are:

Does this book follow the EXACT implementation of these algorithms STRICTLY as any other book I may pick up? (Logical implementation, given any variance of the language implemented in).

Does this book go over Linked-Lists?

Much appreciation,


found_drama says:


The second (easy) question first: yes, McMillan covers linked lists — and doubly- and circularly-linked lists.

RE: the first question… I don’t know that I can rightly say. As I alluded to in the footnotes, my software engineering career was re-routed through a liberal arts discipline, so I’m catching up on some of these (shall we say…?) “EXACT implementations” a bit later on. To the best of my knowledge, McMillan tries to be strict and true in implementing these data structures in JavaScript (inasmuch as the language will allow). That said, I couldn’t say for 100% sure.

Leave a Reply

Your email address will not be published. Required fields are marked *