I have a JSON object with, say, 500 objects in an array. At the moment, to find the one I want, I'm using jQuery's "each" and comparing each object's id with the id I'm looking for, like so:
var desiredID = 500;
$.each(myObj.arrayOfObjects, function(k, oneObject){
if((oneObject.lineid * 1) === (desiredID * 1)){
// hooray! I have found my object
}
});
Is there a better, more efficient way? The array of objects could potentially get impressively large.
(In this instance, I'm using jQuery, but it could be vanilla javascript, too.)
myObj.arrayOfObjects.find(oneObject => (oneObject.lineid * 1) === (desiredID *1))desiredIDby 1...