日期:2014-05-16 浏览次数:20409 次
var x=[];
var res=0;
for(var i=0;i<100000;i++){
x[i]=i;
}
$.each(x,function(i){
res=i;
});
alert(res);
// args is for internal usage only
each: function( obj, callback, args ) {
var name,
i = 0,
length = obj.length,
isObj = length === undefined
------解决方案--------------------
jQuery.isFunction( obj );
if ( args ) {
if ( isObj ) {
for ( name in obj ) {
if ( callback.apply( obj[ name ], args ) === false ) {
break;
}
}
} else {
for ( ; i < length; ) {
if ( callback.apply( obj[ i++ ], args ) === false ) {
break;
}
}
}
// A special, fast, case for the most common use of each
} else {
if ( isObj ) {
for ( name in obj ) {
if ( callback.call( obj[ name ], name, obj[ name ] ) === false ) {
break;
}
}
} else {
for ( ; i < length; ) {
if ( callback.call( obj[ i ], i, obj[ i++ ] ) === false ) {
break;
}
}
}
}
return obj;
},
var res=0;
for(var i=0;i<100;i++){
x[i]=i;
}
$.each(x,function(i){
res=i;
alert(res);
});