Code:
var dataArray: { rootCause: string, countermeasure?: any, signalName: any, importance: any }[] = []
dataArray.push({
rootCause: x.description,
countermeasure: response.countermeasures[ii],
signalName: x.signalName,
importance: x.importance
})
const result = dataArray.group((data: any) => data.rootCause);
I`m just having an array of objects, and group method is for array itself.
Error:
TS2339: Property 'group' does not exist on type '{ rootCause: string; countermeasure?: any; signalName: any; importance: any; }[]'.
In the above code, group method is underlined with the red color.
Official docs to check its working click me
In there, its mentioned that its an experimental one, not sure if we could use it or not.
Similar question click me to what I asked, but mine is not solved.
I made an example code to try out group() on https://onecompiler.com/javascript/, though in the compiler it says "group is not function" :
By this should I conclude that we cant use group method for array?
2
Answers
Alright, So official group() method is not working as intended. Check it out here
But we could have our own walkaround for it.
Let say the data that we have is as follows:
Required output:
Code:
ScreenShot of the output : For more detailed information check here .
This is only available for safari and safari on IOS.