Lodash. How to groupBy except undefined

Viewed 4696

Trying to group up array of object to get unique properties with Lodash

But it takes undefined like unique property if property does not exists

Is there way how to avoid it? and left only existing properties ?

So i'm going to achieve only My Office 1 but with my solution getting undefined and My Office 1 Example array

[
        {office: null},
        {office: 
            {
                name: 'My Office 1'
            }
        }
]

code

Object.keys(_.groupBy(arr, 'office.name')).map((office, index) { ... }
1 Answers
Related