let mainArr = [
"496903611692199",
"245970100361652",
"711023259278888",
"30167380",
"711023259278888",
"30167380",
"245970100361652",
"555"
]
let arr1 = [
"496903611692199",
"245970100361652",
"711023259278888",
"30167380",
];
let arr2 = ["711023259278888",
"30167380"
]
let arr3 = ["245970100361652", "555"]
const counter = {};
// пройти по массиву, заполняя counter
arr.forEach((el) => counter[el] = (counter[el] || 0) + 1);
{
555: 1,
30167380: 2,
496903611692199: 1,
245970100361652: 2,
711023259278888: 2
}
mainArr.reduce((acc, cur) => {
if (!acc[cur]) acc[cur] = 0;
acc[cur]++;
return acc;
}, {})