肯定的:
$.each(theArray, function(index, entry) {
// Use entry.Key and/or entry.Value here
});
或者没有的jQuery在任何现代的浏览器:
theArray.forEach(function(entry) {
// Use entry.Key and/or entry.Value here
});
(forEach
可以在IE8被匀和这样的。)
如果你想停在第一场比赛,然后:
$.each(theArray, function(index, entry) {
if (/* Use entry.Key and/or entry.Value here*/) {
return false; // Ends the "loop"
}
});
或者没有的jQuery在任何现代的浏览器:(some
和every
可以在IE8被垫高和这样)
theArray.some(function(entry) {
if (/* Use entry.Key and/or entry.Value here*/) {
return true; // Ends the "loop"
}
});
或
theArray.every(function(entry) {
if (/* Use entry.Key and/or entry.Value here*/) {
return false; // Ends the "loop"
}
});
注意,如果元件具有相同的键' Key'和'Value',它听起来像是* objects *,而不是数组,所以你拥有的是一个对象数组,而不是一个二维数组。 (反正JavaScript并不是真的有二维数组,但是......) – 2014-10-19 21:44:38