Array-like object in javascript

后端 未结 6 831
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-09 21:52

Looking through the dom.js source from the Closure library I found this (in goog.dom.getElementsByTagNameAndClass_):

if (opt_class) {
var arrayL         


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 22:17

    goog.dom.getElementsByTagNameAndClass_
    

    You are dealing with html collections. An arrayLike object is a snapshot of a node list, rather than the 'live' collection object. It makes it as easy as an indexed array to work with, and less likely to cause complications if you create or delete nodes while looping through its members.

提交回复
热议问题