DEV Community

Discussion on: Need help understanding: Filtering an array of objects in Javascript

Collapse
 
jmatty1983 profile image
Jason Matthews

Looks like the answer to why your initial solution didn't work has been answered. I just wanted to leave a few suggestions.

  • Avoid using == in favor of ===. == Will attempt to type convert and unless that's what you need you can run into some false positives. If it is what you explicitly need you're better off converting and then comparing with === yourself

  • Instead of checking _.isEmpty(thing) == false, you can write !isEmpty(thing). It'll be easier to read when/if you or anyone else has to come back and do additional work on this code.

  • You're mixing two flavors of syntax with an ES5 function definition and an ES6 fat arrow function definition. It's not wrong but unless you have a good reason for it, it's probably better to stick to one again for code legibility down the line.