Source code of Learning JavaScript Data Structures and Algorithms book, third edition.
This is the code repository for Learning JavaScript Data Structures and Algorithms - Third Edition, published by Packt. It contains all the supporting project files necessary to work through the book from start to finish.
JavaScript is one of the most popular programming language nowadays. It is known as the internet language due the fact that the browser understands JavaScript natively, without installing any plugins in it. JavaScript has grown so much that is no longer just a frontend language; it is also present now on the server (NodeJS), database (MongoDB), and mobile devices and is also used in embedded and Internet of Things (IoT) devices.
Learning data structures is very important for any technology professional. Working as a developer means you are able to solve problems with the help of programming languages, and data structures are an indispensable piece of the solutions we need to create to solve these problems. Choosing a wrong data structure can also have an impact on the performance of the program we are writing. That is why, it's important to get to know different data structures and how to apply them properly.
Algorithms are the state of art of computer science. There are so many ways of solving the same problem, and some approaches are better than the others. That is why, it's also very important to know the most famous algorithms. This book was written for beginners who want to learn data structures and algorithms and also for those who are already familiar with data structures and algorithms, but want to learn it using JavaScript.
Happy coding!
All of the code is organized into folders. Each folder starts with a number followed by the application name. For example, Chapter02.
The code will look like the following:
class Stack {
constructor() {
this.items = []; // {1}
}
}
Although this book provides a brief introduction on JavaScript in its first chapter, you will need a basic knowledge of JavaScript and programming logic.
To test the code examples provided by this book, you will need a code editor (such as Atom or Visual Studio Code) so that you can read the code and also a browser (Chrome, Firefox, or Edge).
Also, remember to open the developer tools of the browser so that you can see what is being outputted in the browser's console.
- 01: JavaScript: a quick overview
- 02: ECMAScript and TypeScript Introduction
- 03: Arrays
- 04: Stacks
- 05: Queues and Deques
- 06: LinkedLists
- 07: Sets
- 08: Dictionaries and Hashes
- 09: Recursion
- 10: Trees
- 11: Heap
- 12: Graphs
- 13: Sorting and Searching Algorithms
- 14: Algorithm Design and Techniques
- 15: Algorithm Complexity
- Algorithms using ES2015+ (ES6+)
- New data structures and algorithms
- All chapters rewritten and reviewed
- Three (3) new chapters
- Creation of a Data Structures and Algorithms library that can be used in the browser or with Node.js
- Algorithms tested with Mocha + Chai (test code available in
test
directory) - TypeScript version of the source code included (library and tests)
src/js/index.js
file contains all the data structures and algorithms listed by chapter.
|_examples (how to use each data structure and algorithm, organized by chapter)
|_src
|___js (source code: JavaScript version)
|_____data-structures
|_______models (classes used by DS: Node, ValuePair, ...)
|_____others (other algorithms such as palindome checker, hanoi tower)
|___ts (source code: TypeScript version)
|_____data-structures
|_______models
|_____others
|_test (unit tests with Mocha and Chai for src)
|___js (tests for JavaScript code)
|___ts (tests for TypeScript code)
- Install Node
- Open terminal/cmd and change directoty to this project folder:
cd /Users/.../javascript-datastructures-algorithms
(Linux/Max) orcd C:/.../javascript-datastructures-algorithms
- run
npm install
to install all depencies - To see the examples, run
http-server html
ornpm run serve
. Open your browserhttp:\\localhost:8080
to see the book examples - Or
cd html/chapter01
and run each javascript file with node:node 02-Variables
-
Right click on the html file you would like to see the examples, right click and 'Open with Chrome (or any other browser)'
-
Or open the
examples/index.html
file to easily nagivate through all examples:
Happy Coding!
1st edition | 2nd edition | 3rd edition |
---|---|---|
Book link | Book link | Book link |
Book link - first edition:
Book link - second edition:
Book link - third edition:
Please create an Issue or Pull Request