* Stacks and queues: JS does not have a real stack and queue type
Everything is simulated with an array object.
Stack: An array that can only be accessed from one end and closed at the other
FILO
When to use: In the future only if you want the array to come in and out only
How to use: 2 cases:
1. At the end of the stack: the index of the stack element is no longer changed
Into the stack: Arr.push (new value 1,...)
Outbound: Var last=arr.pop ()
2. Opening and exiting the stack: each time a new element is added, the position of the loaded element will move backwards.
Into the stack: Arr.unshift (new value 1,...);
Outbound: Var first=arr.shift ();
Queue: Only allowed to enter an array from the end, must be set from the beginning
Fifo
End into the queue: Arr.push ();
Start out queue: Var first=arr.shift ();
JavaScript array simulation stacks and queues