1.reduce()
let arr = [1,3,4,5,1,3,4,1,3,5]
const newArr = arr.reduce((obj,item) => {
obj[item] ? obj[item]++ : obj[item] = 1
return obj
},{})
console.log(newArr);
2.forEach()
let newArr = {}
arr.forEach(item => {
newArr[item] ? newArr[item]++ : newArr[item] = 1
})
console.log(newArr);