Skip to content

Commit

Permalink
Merge pull request jashkenas#879 from spadgos/faster-compact
Browse files Browse the repository at this point in the history
Use identity instead of creating a new function in `_.compact`.
  • Loading branch information
jdalton committed Dec 1, 2012
2 parents 6a6de57 + fb78143 commit 0ca412d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@

// Trim out all falsy values from an array.
_.compact = function(array) {
return _.filter(array, function(value){ return !!value; });
return _.filter(array, _.identity);
};

// Internal implementation of a recursive `flatten` function.
Expand Down

0 comments on commit 0ca412d

Please sign in to comment.