JavaScript
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0)
Examples
countOccurrences([1, 1, 2, 1, 2, 3], 1) // 3
标签:arr,val,次数,数组,某个,countOccurrences
From: https://www.cnblogs.com/sunr/p/js_array_countOccurrences.html