close
var your_array=[5,5,5,3,3,2,5];
var counts = {};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });
document.write(counts[5])
--------------
4
全站熱搜
var your_array=[5,5,5,3,3,2,5];
var counts = {};
your_array.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });
document.write(counts[5])
--------------
4