Why I met this problem: I tried to solve an algorithm problem and I need to return the number which appeared most of the times in an array. Like [5,4,3,2,1,1] should return
instead of generating an object like {5: 2, 2: 2, 1: 1}
{5: 2, 2: 2, 1: 1}
generate an array to the effect of
[ {key: 5, val: 2}, {key: 2, val: 2}, {key: 1, val: 1} ]
or... keep track of the sort order in a separate value or key