1let objects = [
2 {office: null},
3 {office: {name: 'My Office 1'}},
4 {office: {name: 'My Office 2'}},
5 {office: {name: 'My Office 1'}},
6];
7
8let path = 'office.name';
9let grouped = _(objects)
10 .filter(object => _.has(object, path))
11 .groupBy(path)
12 .value();
13
14console.log(grouped);