Learning JavaScript Data Structures and Algorithms

I have read a number of books over the years dealing with Algorithms and they all seem to include the same basic list of algorithms that they cover. This book differs from the others only in that it uses JavaScript to explain the algorithms rather than other languages.

My Rating: yesyesyeshalfno





This book starts with a brief summary of the JavaScript language. While this summary is obviously not going to be sufficient for someone trying to learn their first programming language, it should be sufficient for someone already proficient in other languages to understand the JavaScript equivalents to the language they already know to allow them to follow the code throughout the book well enough to understand the algorithms.

The second chapter in the book introduces array in greater detail. This makes a great deal of sense since many of the algorithms the book is going to cover are built on arrays.

Chapter three then goes on to deal with the simplest of the algorithms that can be built using an array - the stack, followed by queues in Chapter four. The code examples in each of these chapters is actually more suited to any classical object oriented language than it is to JavaScript. Creating the structures this way in JavaScript is not considered to be best practice and the author has presumably used this way of writing the code in order to enable it to be more easily translated into other languages.

The priority queue algorithm also introduced in Chapter four is the first that that uses methods that actually include more than a single line of code.

Each of the chapters dealing with a particular algorithm follows the same format. First it describes what the algorithm is. Next it describes the methods needed to implement the algorithm and finally it provides the code for those methods and show you how to use them.

The chapter on Sets is now somewhat outdated as JavaScript actually implemented a built in Set structure in 2015 but the book published a few months earlier does acknowledge that would be the case. The same applies to the chapter on Dictionaries which JavaScript implemented as Map also in 2015 a few months after the book was released. The author made a reasonable compromise at the time by showing how to implement something as close to the about to be introduced objects as possible so much of the chapters continue to be relevant if you use the new built in objects.

The later chapters are more useful because they show more complex algorithms and how to implement them.

Overall the book does a very good job of introducing you to a number of useful algorithms. It uses JavaScript to introduce them as JavaScript is a language many are familiar with and uses constructs that are similar to those in many other languages rather than the best JavaScript code so as to make the algorithms more useful to those wanting to implement them in those other languages.

go to top

FaceBook Follow
Twitter Follow