{"ScriptPreparationCode":"function generateTestData(size) {\r\n const carts = {};\r\n for (let i = 0; i \u003C size; i\u002B\u002B) {\r\n const cartType = \u0060cart_${i}\u0060;\r\n carts[cartType] = Math.random() \u003E 0.1 ? { totalQuantityCount: Math.floor(Math.random() * 100) } : null;\r\n }\r\n return carts;\r\n}\r\n\r\nvar state = {\r\n carts: {\r\n carts: generateTestData(1000000)\r\n }\r\n};\r\n\r\nvar totalQuantitiesCount = 0;","TestCases":[{"Name":"reduce","Code":"Object.values(state.carts.carts).reduce((totalQuantitiesCount, cart) =\u003E totalQuantitiesCount \u002B (cart?.totalQuantityCount ?? 0), 0);","IsDeferred":false},{"Name":"forEach if","Code":"Object.values(state.carts.carts).forEach((cart) =\u003E {\r\n if (cart !== null) totalQuantitiesCount \u002B= cart.totalQuantityCount;\r\n});","IsDeferred":false},{"Name":"for of","Code":"for (const cart of Object.values(state.carts.carts)) {\r\n totalQuantitiesCount \u002B= cart?.totalQuantityCount ?? 0;\r\n}","IsDeferred":false},{"Name":"for of if","Code":"for (const cart of Object.values(state.carts.carts)) {\r\n if (cart !== null) totalQuantitiesCount \u002B= cart.totalQuantityCount;\r\n}","IsDeferred":false},{"Name":"for","Code":"const carts = Object.values(state.carts.carts);\r\nfor (let i = 0; i \u003C carts.length; i\u002B\u002B) {\r\n const cart = carts[i];\r\n if (cart !== null) {\r\n totalQuantitiesCount \u002B= cart.totalQuantityCount;\r\n }\r\n}","IsDeferred":false},{"Name":"forEach","Code":"Object.values(state.carts.carts).forEach((cart) =\u003E totalQuantitiesCount \u002B= (cart?.totalQuantityCount ?? 0));","IsDeferred":false}]}