js判断数组中某个元素个数实例代码
var arr = [1,2,1];
var map = {};
for(var i = 0; i < arr.length; i++){
var ai = arr[i];
if(!map[ai]){
map[ai] = 1;
}else{
map[ai]++;
}
}
console.log(map);
var array = [1,2,3,2,3,3];
var num = array.filter(function(n){
return n === 3;
}).length;