About Stacks:
- The stack is a LIFO data structure, that is, LIFO, and the last item added is first removed.
- The insertion of the stack is called push-in, and removal is called pop-up, only at the top of the stack.
Stack method for arrays:
- Push (), which can pass in any number of parameters that are added one at a time to the end of the array, which returns the length of the final array.
- Pop (), which removes the last item from the array and returns the item.
About queues:
- Queue data structure access rules are different from the stack, its rules are FIFO, that is, first-out, the first to add items are removed.
Queue methods for arrays:
- Shift (), which moves the first item of the array and returns the item.
- The shift () and push () mates use the behavior FIFO that can mimic the queue.
- Unshift (), which can pass in any number of parameters that are added to the front of the array one by one, which returns the final number length.
- Note: example var arr = new Array (); Arr.unshift ("A", "B"); Arr.unshift ("C"); The order of the array items is c,a,b.
- Unshift () and pop () can be used in reverse to mimic the queue, corresponding to shift () and push ().
- IE7 and earlier versions of the Unshift () method always return undefined instead of the new length of the array, IE8 returns the correct length value in non-compatibility mode.
Fifth reference type--NOTE 3