Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

Check if an element is present in an array that is property of an object

$
0
0

I'm using Lodash and I want to check if an element is present inside an array that is actually a property (in my case "feature") of an object that is itself part of an array. I tried with _.some and _.find but I didn't succeed

const element = 'Hello'

const Array = [
 { name: something
   surname: somethingelse
   features:[element, ...]
}, 
]

async featuresCheck () {
  if (_.some(Array,{features:element})){
    console.log('element included')
  } else {
    console.log('element not included')
  }
}

Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>