just checking Stack Overflow and noticed that this question may have not been answered yet: How to get the occurrences of elements in a given array - JavaScript.
let array = [6, 1, 5, 1, 1, 8, 2, 4, 6, 0] // Elements in array
getOccurrence(array) /* returns
[
{occurrence: x, item: array[y]},
{occurrence: ..., item: ...},
{...},
]
where 'x' is the frequency of an item in the array.a
*/
If this is possible using any algorithms, please share.