How to determine if Javascript array contains an object with an attribute that equals a given value?

I have an array like

vendors = [{
    Name: 'Magenic',
    ID: 'ABC'
  },
  {
    Name: 'Microsoft',
    ID: 'DEF'
  } // and so on... 
];

How do I check this array to see if "Magenic" exists? I don’t want to loop, unless I have to. I’m working with potentially a couple thousand records.

49 thoughts on “How to determine if Javascript array contains an object with an attribute that equals a given value?”

Leave a Comment