{"ScriptPreparationCode":"function groupBy(array, mapper) {\r\n return array.reduce(\r\n (acc, item) =\u003E {\r\n const key = mapper(item);\r\n const items = acc[key] ?? (acc[key] = []);\r\n items.push(item);\r\n return acc;\r\n }, {},\r\n );\r\n}\r\n\r\nvar data = [{\r\n name: \u0022John\u0022,\r\n age: 20,\r\n occupation: null,\r\n },\r\n {\r\n name: \u0022Jane\u0022,\r\n age: 30,\r\n occupation: \u0022student\u0022,\r\n },\r\n {\r\n name: \u0022Jack\u0022,\r\n age: 40,\r\n occupation: \u0022student\u0022,\r\n },\r\n {\r\n name: \u0022Simon\u0022,\r\n age: 50,\r\n occupation: \u0022student\u0022,\r\n },\r\n {\r\n name: \u0022Mary\u0022,\r\n age: 60,\r\n occupation: null,\r\n },\r\n {\r\n name: \u0022George\u0022,\r\n age: 70,\r\n occupation: \u0022influencer\u0022,\r\n },\r\n]","TestCases":[{"Name":"Object.groupBy","Code":"return Object.groupBy(data, item =\u003E item.occupation)","IsDeferred":false},{"Name":"Manual groupBy","Code":"return groupBy(data, item =\u003E item.occupation)","IsDeferred":false}]}