Can you provide an example of syntax where you'd provide a string with the path to a deeply nested object property to use in ES6 map or where you'd be able to provide an object that describes a property and value to filter on? If such exists, I have never seen it described anywhere. AFAIK those methods always take a function.
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 π¨
I don't think one method does exist off the top of my head. Can you give me a data structure snippet to visualize.
I guess you might want to use entries and perhaps flat, not working on nested data but flat copies, that's got to be more efficient.. maybe. IDK but I agree that convince sounds like the winner here. Anyway I always check this sort of opinion, it's interesting. π
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.
Can you provide an example of syntax where you'd provide a string with the path to a deeply nested object property to use in ES6 map or where you'd be able to provide an object that describes a property and value to filter on? If such exists, I have never seen it described anywhere. AFAIK those methods always take a function.
I don't think one method does exist off the top of my head. Can you give me a data structure snippet to visualize.
I guess you might want to use entries and perhaps flat, not working on nested data but flat copies, that's got to be more efficient.. maybe. IDK but I agree that convince sounds like the winner here. Anyway I always check this sort of opinion, it's interesting. π
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).