一行代码:
function count(arr, item) {
    return arr.filter(p=>p === item).length;
}