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.
Best Answer
No need to reinvent the
wheelloop, at least not explicitly (using arrow functions, modern browsers only):or, better yet, as it allows the browser to stop as soon as one element is found that matches, so it's going to be faster:
EDIT: If you need compatibility with lousy browsers then your best bet is: