This is a jquery "feature" ;-). According to the sources it treats a variable as an object if there is no length
property defined:
https://github.com/jquery/jquery/blob/master/src/core.js#L589
var name,
i = 0,
length = obj.length,
isObj = length === undefined || jQuery.isFunction( obj );
^---------
And if isObj
is false
- then see https://github.com/jquery/jquery/blob/master/src/core.js#L608
if ( isObj ) {
// not your case, ommitted
} else {
for ( ; i < length; ) {
if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
break;
}
}
}
As you can see it iterates over i
from 0
to length