{"ScriptPreparationCode":"var arr = new Array(2000000);\r\narr.fill({\r\n id: 0\r\n});\r\narr = arr.map((el, idx) =\u003E el.id = idx);\r\n\r\nvar findItemIndex = (idToFind, list) =\u003E {\r\n var index = -1\r\n for (var i = 0; i \u003C list.length; i\u002B\u002B) {\r\n if (list[i].id === idToFind) {\r\n index = i;\r\n break;\r\n }\r\n }\r\n\r\n return index;\r\n}\r\nvar itemsToUpdate = [{\r\n id: 100,\r\n updates: {\r\n name: \u0022111\u0022\r\n }\r\n}, {\r\n id: 200,\r\n updates: {\r\n name: \u0022111\u0022\r\n }\r\n}, {\r\n\r\n id: 400,\r\n updates: {\r\n name: \u0022111\u0022\r\n }\r\n\r\n}, {\r\n id: 600,\r\n updates: {\r\n name: \u0022111\u0022\r\n }\r\n\r\n}, {\r\n id: 800,\r\n updates: {\r\n name: \u0022111\u0022\r\n }\r\n\r\n}]","TestCases":[{"Name":"update via findIndex","Code":"itemsToUpdate.forEach((t) =\u003E {\r\n const storedIndex = arr.findIndex((tD) =\u003E {\r\n \treturn tD.id === t.id\r\n })\r\n \r\n if(storedIndex \u003E= 0){\r\n\r\n\tarr[storedIndex] = {\r\n ...arr[storedIndex],\r\n ...t.updates\r\n }\r\n }\r\n \r\n})","IsDeferred":false},{"Name":"for loop update ","Code":"itemsToUpdate.forEach((t) =\u003E {\r\nconst storedIndex = findItemIndex(t.id, arr)\r\n \r\n if(storedIndex \u003E= 0){\r\n\tarr[storedIndex] = {\r\n ...arr[storedIndex],\r\n ...t.updates\r\n }\r\n }\r\n })","IsDeferred":false}]}