Skip to content

Instantly share code, notes, and snippets.

@prettymuchbryce
Last active August 29, 2015 14:07
Show Gist options
  • Save prettymuchbryce/98427a8bc8ab980199d1 to your computer and use it in GitHub Desktop.
Save prettymuchbryce/98427a8bc8ab980199d1 to your computer and use it in GitHub Desktop.
lodash and underscore .where
//underscore does not search nested objects in .where
//lodash does
var _ = require('underscore');
var lodash = require('lodash');
var object = {
nestedObject: {
value: true
}
};
var list = [object];
console.log(_.where(list, { nestedObject: { value: true } } ).length); //0
console.log(lodash.where(list, { nestedObject: { value: true } } ).length); //1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment