MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/rigrfe/i_dont_know_where_to_start/hoxeyqe/
r/badcode • u/[deleted] • Dec 17 '21
24 comments sorted by
View all comments
Show parent comment
16
Or maybe:
key.split('.').slice(0,4).reduce((acc, key) => acc[key] || null, data)
2 u/[deleted] Dec 17 '21 if you don't mind using a lib you can just _.get(object, path) and move on 1 u/[deleted] Dec 19 '21 Using libraries is overrated
2
if you don't mind using a lib you can just _.get(object, path) and move on
_.get(object, path)
1 u/[deleted] Dec 19 '21 Using libraries is overrated
1
Using libraries is overrated
View all comments
Show parent comment
16
u/[deleted] Dec 17 '21
Or maybe:
key.split('.').slice(0,4).reduce((acc, key) => acc[key] || null, data)