Why is it possible to query jQuery('div') like an array?

后端 未结 5 1323
礼貌的吻别
礼貌的吻别 2021-01-05 01:59

I got another question regarding jQuery\'s architecture. $(\'div\') constructs a new jQuery object:

$(\'div\') instanceof jQuery; /         


        
5条回答
  •  情话喂你
    2021-01-05 02:56

    I am not sure what this "array-like" craziness is from the other answers. There is no standard terminology for "array-like".

    The actual difference here is the difference between an actual array, which is a collection of elements versus a linked list which is a collection of references. In reference to the DOM a linked list is properly referred to as a node list. These articlea have more information:

    http://www.mindcracker.com/Story/1016/interview-question-difference-between-linked-list-and-array.aspx

    http://www.sitepoint.com/a-collection-is-not-an-array/

    http://blog.duruk.net/2011/06/19/nodelists-and-arrays-in-javascript/

提交回复
热议问题