How does a jQuery instance appear as an array when called in console.log?

后端 未结 5 1917
一个人的身影
一个人的身影 2021-01-03 15:58

When entered into a JavaScript console, a jQuery object appears as an array. However, it\'s still an instance of the jQuery object.

var j = jQuery();
=> [         


        
5条回答
  •  无人及你
    2021-01-03 16:18

    It returns an empty array, because it did nothing - array of elements affected.

    Proper way to inspect would be

    console.log(jQuery);
    

    if you would do

    console.log(jQuery('div'));
    

    you will see that it returns array of elements.

提交回复
热议问题