_.compact = function(obj) {
+ return _.filter(obj, _.identity);
+ };
diff --git a/docs/underscore.html b/docs/underscore.html index c9fd74974..976d4d062 100644 --- a/docs/underscore.html +++ b/docs/underscore.html @@ -1042,9 +1042,27 @@
Trim out all falsy values from an object.
+ + _.compact = function(obj) {
+ return _.filter(obj, _.identity);
+ };
Trim out all falsy values from an array.
- - _.compact = function(array) {
- return _.filter(array, _.identity);
- };
_.partition([0, 1, 2, 3, 4, 5], isOdd); => [[1, 3, 5], [0, 2, 4]] ++ +
+ compact_.compact(list)
+
+ Returns a copy of the list with all falsy values removed.
+ In JavaScript, false, null, 0, "",
+ undefined and NaN are all falsy.
+
+_.compact([0, 1, false, 2, '', 3]); +=> [1, 2, 3]
_.rest([5, 4, 3, 2, 1]); => [4, 3, 2, 1] -- -
- compact_.compact(array)
-
- Returns a copy of the array with all falsy values removed.
- In JavaScript, false, null, 0, "",
- undefined and NaN are all falsy.
-
-_.compact([0, 1, false, 2, '', 3]); -=> [1, 2, 3]