|
|
|
|
|
by Klathmon
2930 days ago
|
|
Yeah the iteratee shorthand stuff in lodash is massively convenient, however I'm starting to shy away from it in favor of more "obvious" approaches like your second example. Although that being said, for deep property access like you have, i still reach for lodash's `get`, or more recently i'm beginning to use the new stage-1 proposal for "optional chaining" (also known as null-conditional operator in C#) [0]. That turns your second example into: Object.values(object).map(i => i.myProperty?.mySubProperty)
And honestly I might even reach for destructuring depending on the use case: Object.values(object).map(({myProperty}) => myProperty?.mySubProperty)
As nice as lodash's syntax is, it can be confusing for those who don't know it, and even I need to step back sometimes when I see it used heavily somewhere and almost replay what is happening in my head.[0] https://github.com/tc39/proposal-optional-chaining |
|