Returns a copy of the array with all falsy values removed. In JavaScript, false, null, 0,"", undefined and NaN are all falsy.
返回的数组将不再包括,false,null,0,"",undefined
1 _.compact([0, 1, false, 2, '', 3]); 2 => [1, 2, 3]
源码:
_.compact = function(array) { return _.filter(array, function(value){ return !!value; }); }