(iv) The dynamic nature of an array-like object

Source: Internet
Author: User

-The three collections of Htmlcollection, NodeList and NamedNodeMap are "dynamic" and are the objects of life and breathing.

-they are actually the result of executing queries based on the DOM structure, so changes in the DOM structure can automatically reflect these objects.

-Each time the document structure changes, they will be updated. As a result, they always keep the latest and most accurate information.

Let me take a look at the following code:

    var divs = document.getElementsByTagName ("div");     var i = 0;      while (I < divs.length) {      document.body.appendChild (document.createelement ("div"));      I+ +;    }

This is going to be a dead loop!

Because DIVs is a collection of htmlcollection obtained through getElementsByTagName (), it is "dynamic". Each time the Document.body.appendChild (DIV) is executed, the divs.length increases.

(iv) The dynamic nature of an array-like object

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.