I don't see anyone talking about what to me is the biggest advantage of lodash--the various syntaxes you can use for iteratees. So, _.map(myObj, 'someProp.innerArray[0]'), or _.find(someArray, {color: 'green'}) just completely blows the hell out of anything you could write yourself in the 10 seconds it took me to write that. And then there's the fact that the Collection methods let you treat arrays and objects as basically the same.
Also, studying the lodash docs really gives you a feel for what's possible in functional programming and some ways you might want to use it to solve your own problems. I think really understanding the lodash docs made me a much better programmer. I'd highly recommend this for people who don't already automatically reach for FP on a regular basis.
To me the downside is the cyclomatic complexity is unknown for all the functions. So you have no idea what the performance impact is of deciding to use a lodash function, whereas you do know for your own.
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 π¨
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.
I don't see anyone talking about what to me is the biggest advantage of lodash--the various syntaxes you can use for iteratees. So, _.map(myObj, 'someProp.innerArray[0]'), or _.find(someArray, {color: 'green'}) just completely blows the hell out of anything you could write yourself in the 10 seconds it took me to write that. And then there's the fact that the Collection methods let you treat arrays and objects as basically the same.
Also, studying the lodash docs really gives you a feel for what's possible in functional programming and some ways you might want to use it to solve your own problems. I think really understanding the lodash docs made me a much better programmer. I'd highly recommend this for people who don't already automatically reach for FP on a regular basis.
To me the downside is the cyclomatic complexity is unknown for all the functions. So you have no idea what the performance impact is of deciding to use a lodash function, whereas you do know for your own.
The first part of what you mentioned, I'm not convinced that this is not already covered by popular es6 array methods unless I am missing something?
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).