DEV Community

Discussion on: How (and Why) To Implement a Stack in JavaScript

Collapse
 
mattpopovich profile image
Matt Popovich • Edited

This is more of a guide to implementing this specific data structure in JavaScript, as a means of teaching the concept of a stack. It's true that arrays can do all that stacks can do and more, so in most real-world situations, you'd probably want to use an array, unless you specifically want to prevent the use of methods other than .push() and pop(). Beyond that, this is also useful as a thought experiment of the type you might be asked in a technical interview.