{"ScriptPreparationCode":"var arr = new Array(150000);\r\narr.fill({\r\n id: 0\r\n});\r\narr = arr.map((el, idx) =\u003E el.id = idx);\r\nvar foo1 = Math.floor(Math.random() * 150000);\r\nvar foo2 = Math.floor(Math.random() * 150000);\r\nvar foo3 = Math.floor(Math.random() * 150000);\r\nvar foo4 = Math.floor(Math.random() * 150000);\r\nvar foo5 = Math.floor(Math.random() * 150000);","TestCases":[{"Name":"1","Code":"function firstWay(id) {\r\n return arr.find(user =\u003E user.id === id);\r\n}\r\n\r\nfirstWay(foo1);\r\nfirstWay(foo2);\r\nfirstWay(foo3);\r\nfirstWay(foo4);\r\nfirstWay(foo5);","IsDeferred":false},{"Name":"enum","Code":"var userEnum = {};\r\nfunction secondWay(id) {\r\n if (Object.keys(userEnum).length === 0) {\r\n arr.forEach(user =\u003E userEnum[user.id] = user);\r\n }\r\n return userEnum[id];\r\n}\r\n\r\nsecondWay(foo1);\r\nsecondWay(foo2);\r\nsecondWay(foo3);\r\nsecondWay(foo4);\r\nsecondWay(foo5);","IsDeferred":false},{"Name":"findindex","Code":"function thirdWay(id) {\r\n const idx = arr.findIndex(user =\u003E user.id == id);\r\n return (idx !== -1) ? arr[idx] : null;\r\n}\r\n\r\nthirdWay(foo1);\r\nthirdWay(foo2);\r\nthirdWay(foo3);\r\nthirdWay(foo4);\r\nthirdWay(foo5);","IsDeferred":false}]}