jashkenas/underscore — pull request #1461 by landau (2014-02-10 06:21:35+00:00)
Title: add omitValues function

After had already written this, I read the contributing file which mentions looking up existing functionality in contrib. There is an `omitWhen` method which allows you to pass a predicate for matching against values. While this achieves the same thing, the functionality is not explicit, unlike `omitValues`.

I needed the functionality and I forgot about contrib. No biggy if you think this is to analogous to `omitWhen`.

If you need a use case consider a need for default values, but an object's value for any key could potentially be an empty string. In my mind, I would think `_.defaults` would be the right choice, but it doesn't see an empty string as an unset value.

```
var props = { age: 43 };
var instanceProps = { name: '' };
var defaults = { name: 'unknown' };
_.defaults(props, instanceProps, defaults); // { age: 43, name: '' }
_.defaults(props, _.omitValues(instaceProps, ''), defaults); // { age: 43, name: 'unknown' }
```

One thought on matching values. The behavior will likely be incorrect for objects unless you pass the reference directly as a value to omit. This should probably be of note that you can only omit primitives unless you pass in reference.