function findAllOccurrences(arr, target) { let res = []; arr.forEach((i, index) => { if(i === target) res.push(index); }); return res; } function findAllOccurrences(arr, target) { return arr.reduce((res, i, index) => { if(i === target) res.push(index); return res; }, []); } JavaScript中forEach...