Is there some elegant way of filtering out falsey properties from this object with lodash/underscore? Similar to how _.compact(array)
removes falsey elements fr
Unfortunately I cannot direclty comment on the posts above yet, so I create this extra post.
Since Lodash v4 the functionality described above has been moved to _.pickBy. With _.identity
as default you could also change your code to:
var filtered = _.pickBy(obj);
See this JSBin for a working example.