2016-06-24 2 views

답변

1

예 그것은 동기의,

function every(collection, callback, thisArg) { 
     var result = true; 
     callback = lodash.createCallback(callback, thisArg, 3); 

     var index = -1, 
      length = collection ? collection.length : 0; 

     if (typeof length == 'number') { 
     while (++index < length) { 
      if (!(result = !!callback(collection[index], index, collection))) { 
      break; 
      } 
     } 
     } else { 
     forOwn(collection, function(value, index, collection) { 
      return (result = !!callback(value, index, collection)); 
     }); 
     } 
     return result; 
    }