/**
* A specialized version of `_.forEach` for arrays without support for iteratee shorthands.
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`.
*/
function arrayEach(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) { // 回调返回false则中断循环
break;
}
}
return array;
}
/**
* A specialized version of `_.forEachRight` for arrays without support for iteratee shorthands.
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`.
*/
function arrayEachRight(array, iteratee) {
var length = array == null ? 0 : array.length;
while (length--) { // 递减,while(0)会停止
if (iteratee(array[length], length, array) === false) {
break;
}
}
return array;
}