Summary

In this chapter, you learned about the stack data structure. We implemented our own algorithm that represents a stack, and you learned how to add and remove elements from it using the push and pop methods.

We compared different syntaxes that can be used to create the Stack class, and presented the pros and cons of each one. We also covered how to solve one of the most famous problems in Computer Science using stacks.

In the next chapter, you will learn about queues, which are very similar to stacks, but use a principle different than LIFO.

Get Learning JavaScript Data Structures and Algorithms - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.