Understanding the Sort Method of Arrays

How to use JavaScript’s sort Photo by Jozsef Hocza on Unsplash The JavaScript array sort() is used to sort array elements. By default, the array will sort in ascending order, but we can change it. This method will change the original array. We can also provide our comparing function to implement custom sorting. var array = …

Implementing a Stack in JavaScript

They’re like arrays with more structure and rules Image by Brooke Lark from Unsplash Stacks are data structures that follow the Last-In-First-Out (LIFO) principle, meaning the last item inserted into a stack is the first one to be deleted. In other words, a stack is a list of elements that are accessible only from one end of …

Implementing a Queue in JavaScript

A look at the queue data structure Image by Levi Jones on UnSplash A queue is a list — similar to the real world queue. The one who gets into the queue first is the one who is removed first from the queue. Technically speaking, this process is called first in, first out (FIFO). The element which is …

Design a site like this with WordPress.com
Get started