for (var a = [2, 7, 5, 1, "a", 5, 2, 2, "a", "a", 7, 0], b = {}, i = 0; i < a.length; i++) b[a[i]] ? b[a[i]]++ : b[a[i]] = 1; alert(JSON.stringify(Object.keys(b) .map(function (c) { return [c, b[c]] })));