No, it is not recursive. The function on line 222 is the one on jQuery's prototype ($.fn
), while the function it calls is jQuery.each
- a static property which is defined in line 566. Notice how extend works: If no object to extend is given, it uses this
. It is both applied on jQuery
and jQuery.fn
in different sections of the code.
so how exactly does this work?
$obj.each(callback)
is calling the $.fn.each
method, which applies $.each
on the jQuery instance (the DOM wrapper) itself: line 223.
Now, in $.each
, there are four cases: With or without supplied args
array, and on an array-like structure or on other objects. You didn't pass additional args, and jQuery instances have a length
property and have the DOM elements in numeric indices, so the loop in line 596 will be executed. So your call is equivalent to
for (var i=0, len=$obj.length; i<len; i++)
if ( callback.call($obj[i], i, $obj[i]) === false ) break;