Count Distinct Elements In Array Javascript Methods For Querying