Fifth reference type--NOTE 3

Source: Internet
Author: User

About Stacks:

  1. The stack is a LIFO data structure, that is, LIFO, and the last item added is first removed.
  2. 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:

  1. 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.
  2. Pop (), which removes the last item from the array and returns the item.

About queues:

  1. 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:

  1. Shift (), which moves the first item of the array and returns the item.
  2. The shift () and push () mates use the behavior FIFO that can mimic the queue.
  3. 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.
  4. Note: example var arr = new Array (); Arr.unshift ("A", "B");  Arr.unshift ("C"); The order of the array items is c,a,b.
  5. Unshift () and pop () can be used in reverse to mimic the queue, corresponding to shift () and push ().
  6. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.