{"ScriptPreparationCode":"var ids = Array.from(Array(10000).keys())\r\n\r\nvar data = ids.map(item =\u003E ({ id: item, random: Math.random() }))","TestCases":[{"Name":"Object.fromEntries with Array.map","Code":"// Create the dictionary\r\n// Using \u0060Object.fromEntries\u0060 and \u0060Array.map\u0060\r\nconst dictionary = Object.fromEntries(\r\n data.map((item) =\u003E [\r\n // Key\r\n item.id,\r\n // Item\r\n item,\r\n ])\r\n);\r\n\r\n// Utilize it, to test the performance of the dictionary itself as well.\r\nids.map((id) =\u003E dictionary[id]);","IsDeferred":false},{"Name":"new Map with Array.map","Code":"// Create the dictionary\r\n// Using \u0060new Map\u0060 and \u0060Array.map\u0060\r\nconst dictionary = new Map(\r\n data.map((item) =\u003E [\r\n // Key\r\n item.id,\r\n // Item\r\n item,\r\n ])\r\n);\r\n\r\n// Utilize it, to test the performance of the dictionary itself as well.\r\nids.map((id) =\u003E dictionary.get(id));","IsDeferred":false},{"Name":"Reduce (reusing object)","Code":"// Create the dictionary\r\n// Using \u0060Array.reduce\u0060\r\n// And reusing the object\r\nconst dictionary = data.reduce((obj, item) =\u003E {\r\n obj[item.id] = item;\r\n return obj;\r\n}, {});\r\n\r\n// Utilize it, to test the performance of the dictionary itself as well.\r\nids.map((id) =\u003E dictionary[id]);","IsDeferred":false},{"Name":"Reduce (creating temporary objects)","Code":"// Create the dictionary\r\n// Using \u0060Array.reduce\u0060\r\n// And NOT reusing the object\r\nconst dictionary = data.reduce((obj, item) =\u003E {\r\n return {\r\n ...obj,\r\n [item.id]: item\r\n };\r\n}, {});\r\n\r\n// Utilize it, to test the performance of the dictionary itself as well.\r\nids.map((id) =\u003E dictionary[id]);","IsDeferred":false}]}