Howβs it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK π¬π§
Education
10 plus years* active enterprise development experience and a Fine art degree π¨
constarr=[{firstName:'John',lastName:'Smith',offspring:[{name:'Katie',gender:'F'},{name:'Mark',gender:'M'}],{firstName:'Jill',lastName:'Jones',offSpring:[{name:'Doug',gender:'M'}]}];arr.find(person=>person.offspring.find...// Point taken this is a bit more wordyπ
So in other words, you can't do it out of the box with ES6 functions--you have to write additional functionality yourself (which your team is then responsible for testing and maintaining).
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
So, if your data structure is
[{firstName: 'John', lastName: 'Smith', offspring: [{name:'Katie', gender: 'F'}, {name: 'Mark', gender: 'M'}],
{firstName: 'Jill', lastName: 'Jones', offSpring: [{name: 'Doug', gender: 'M'}]}]
and you're looking for someone whose firstborn is a son (in case of pestilence), you can do _.find(users, ['offspring[0].gender', 'M'])
Or if you want the last name of the second user, you can do _.get(users, '[1].lastName')
Or if you want to find all users with offspring
_.filter(users, 'offspring.length')
I just don't see easily being able to do that with native ES6 functions out of the box.
So in other words, you can't do it out of the box with ES6 functions--you have to write additional functionality yourself (which your team is then responsible for testing and maintaining).