underscore.js源码解析【集合】
// Collection Functions // -------------------- // The cornerstone, an `each` implementation, aka `forEach`. // Handles raw objects in addition to array-likes. Treats all // sparse array-likes as if they were dense. /* params: 数组、对象或类数组对象,函数,函数执行环境 */ _.each = _.forEach = function(obj, iteratee, context) { iteratee = optimizeCb(iteratee, context); var i, length; if (isArrayLike(obj)) {// 数组或类数组 for (i = 0, length = obj.length; i < length; i++) { iteratee(obj[i], i, obj);// item index obj } } else {// 对象 var keys = _.keys(obj);// 返回键的数组 for (i = 0, length = keys.length; i < length; i++) {