Let arr = ['zhou', 'zhou', 'zhi', 'zhi', 'zhou', 'zhi', 'hu']; let sum = arr.reduce((pre, cur) => { // console.log(pre, cur); if (cur in pre) { pre[cur]++; } else { pre[cur] = 1; } return pre; }, {}); console.log(sum); // let arr1 = [1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 4, 56, 2] let result = arr1.reduce((pre, cur) => {if (! pre.includes(cur)) { return pre.concat(cur) } else { return pre; } }, []) console.log(result); Let result1 = [{subject: 'math', score: 10}, {subject: 'Chinese ', score: 20}, {subject:' Chinese ', score: 20} 'english', score: 30 } ]; var sum1 = result1.reduce(function (prev, cur) { return cur.score + prev; }, 0); console.log(sum1) //60Copy the code