Extracting the most duplicate value from an array in JavaScript (with jQuery)

Posted by TK on Stack Overflow See other posts from Stack Overflow or by TK
Published on 2010-03-13T22:31:08Z Indexed on 2010/03/13 22:35 UTC
Read the original article Hit count: 171

Filed under:
|
|

I have several array to deal with. I need to extract the most duplicate value from each array.

From [3, 7, 7, 7], I need to find the value 7. Each array size is 4. For now, I don't have to think about when the most duplicate values are more than one such as [3, 7, 7, 7]. All the values are a number.

I looked around the web. I found several ways to make an array to become uniq(). But I haven't found a way to get the duplicate value. I am using jQuery, but raw JavaScript is fine for this task.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about arrays