What is stored in Q
?
Q = $('div');
Q2 = document.getElementsByTagName('div');
I can access each HTML element by using Q[index]
, similar to Q2[index]
; which makes it seem like Q
is an array of HTML Elements.
On the other hand, I can do Q.filter()
, but I cannot do Q2.filter()
; which makes it seem like Q
is an array of jQuery objects.
Or is it both, where Q
is a jQuery object that holds a bunch of HTML elements? If this was the case, wouldn't console.log()
detect Q
as an object with a collection of objects inside it? This fiddle, http://jsfiddle.net/rkw79/3s7tw/, shows that they are the same.
Note: I am aware that Q.eq(index)
will return an object that can use jQuery methods. I'm just wondering what exactly is Q
The result is a jQuery
object that behaves like both an array of HTMLElements
which you get using []
and an array
of jQuery
objects which you get using eq(index)
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With