如果您尝试使用下划线 (http://underscorejs.org/#zip) 中的 zip 功能,您可以执行以下操作:
var combined = _.zip(demo, demo3);
$.each(combined, function(index, value) {
// value[0] is equal to demo[index]
// value[1] is equal to demo3[index]
});
演示:http: //jsfiddle.net/lucuma/jWbFf/
_zip Documentation: Merges together the values of each of the arrays with the values at the corresponding position. Useful when you have separate data sources that are coordinated through matching array indexes. If you're working with a matrix of nested arrays, zip.apply can transpose the matrix in a similar fashion.
http://underscorejs.org/#zip
All that said, a plain for loop is quite easy and efficient in this case.