const arr = [0,1,4,3,4]; const max = Math.max(...arr); let res = []; arr.forEach((item, index) => item === max ? res.push(index): null); console.log(res);