Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 14
    Rockstar. Thank you, this was incredibly helpful for solving a slightly different problem. Filtering out an array of objects based on an array of values in a react component: const filteredResults = this.state.cards.filter( result => !this.state.filterOut.includes(result.category) ) where this.state.cards in an array of objects and this.state.filterOut is an array of values that correspond the 'category' key in the objects that I wanted to remove. Commented Jun 8, 2017 at 8:07
  • 1
    I know, it's an older response, but I simply wanted to let you know that I liked this response a whole lot more and it helped me with one of my problems I had. It is very readable and thus it was easier for me to understand the issue better. Commented May 24, 2018 at 6:54
  • 1
    includes will only work from ES7. If you using ES6 use the accepted solution. Commented Jun 20, 2018 at 16:24
  • 2
    Arrow functions FTW. Much nicer than the old school callback! Commented Sep 1, 2020 at 19:43
  • Thank you very much, it really helped me a lot and I learned a new paradigm it's great thank you Commented Nov 19, 2022 at 15:28