Is there a faster way to get and move items in array?
I have 2 arrays of objects. Now that object has Id property. Now if I have 3 array of just Ids, what is the better and faster way of finding objects from array1 and move them to array2.
Thanks a lot for answering..
Sample code:
Person = function(id, fn, ln) {
this.id = id,
this.firstName = fn,
this.lastName = ln
}
array1 = new Array();
// add 500 new Person objects to this array
array2 = new Array();
// add some other new Person objects to this array
function moveArrayItems(ids) {
// ids is an array of ids e.g. [1,2,3,4,5,6,...]
//Now I want to find all the person objects from array1 whose ids match with the ids array passed into this method. Then move them to array2.
//What is the best way to achive this?
}