if have array of objects called filteredlist , function such :
function buildlist(filteredlist, p1, p2, p3) { var resultlist = []; (var =0; < filteredlist.length; i++) { if (filteredlist[i].type === 'global' && filteredlist[i].p1 === p1 && filteredlist[i].p2 === p2 && filteredlist[i].p3 === p3) resultlist.push(filteredlist[i]); } return resultlist; } what performance difference if instead of looping through array do, : filteredlist.filter(rebuildlist)
rebuildlist being function checking same conditions buildlist
would same ? (looping through each element)
can think of more optimized , efficient way ? i'm calling function buildlist many times in project , consumes great amount of time.
you can use array.prototype.filter method. example coming soon
regarding performance should read here: fastest way find item in javascript array
Comments
Post a Comment