You need to sign in to do that
Don't have an account?
Alexander Atkinson
Javascript: "Array.find()" is really slow. How can I speed it up or is there a better alternative?
So I have some code that is really inefficient. It has an array of objects all created from an apex query. When I move somebody to a new location, the component will fire an event with the moved persons information stored. This is then used in a "find" method for my array of objects to find the object inside of the array to edit and update so the component will update visually.
The problem is this line of code becomes extremely inefficient when passing 200 objects.
Sample:
The problem is this line of code becomes extremely inefficient when passing 200 objects.
Sample:
var titleid = event.getParam("titleid"); var title = event.getParam("title"); var maxSeats = event.getParam("maxSeats"); var seatsInUse = event.getParam("seatsInUse"); var item = event.getParam("item"); //This is the item that was moved. var allGuestsList = component.get("v.allItems"); //This is the array of objects //Search guest list for matching guest to edit the array so the component will update graphically. var actualGuest = allGuestsList.find(function(moving){return moving.id == item.id;}); //***REALLY INEFFICIENT***
Array.prototype.includes also work