callback.apply( object[ name ], args
is simply calling function
)callback
with
object[name]
as context (this
) and
args
as arguments. jQuery provides a way to break a loop by
returning false
, as stated in href="http://api.jquery.com/jquery.each/" rel="nofollow">the
docs:
We can break the
$.each()
loop at a particular
iteration by making the callback function returnfalse
.
Returning non-false is the same as acontinue
statement in a
for loop; it will skip immediately to the next
iteration.
So, this piece of
code:
if ( callback.apply( object[ name ],
args ) === false ) {
break;
}
checks if the
function returns false
, and if yes, breaks the
loop.
If we skip the context part,
the code could look like this (in ES6):
if
(callback(...args) === false) {
break;
}
No comments:
Post a Comment