groupby undefined lodash code example
Example: lodash group by except group null items
let objects = [
{office: null},
{office: {name: 'My Office 1'}},
{office: {name: 'My Office 2'}},
{office: {name: 'My Office 1'}},
];
let path = 'office.name';
let grouped = _(objects)
.filter(object => _.has(object, path))
.groupBy(path)
.value();
console.log(grouped);