let config = [
{
"id": 620847764,
"text": "V"
},
{
"id": 620847764,
"text": "B"
},
{
"id": 620847764,
"text": "B"
},
{
"id": 620847764,
"text": "B"
}
]
let a = config[id].length
console.log(a);
const getUniqueIdsCount = (arr) => arr.reduce(
(acc, item) => acc.add(item.id),
new Set(),
).size;
console.log(getUniqueIdsCount(config)); // -> 1
const getIdsCountById = (arr, id) => arr.reduce(
(acc, item) => item.id === id ? acc + 1 : acc,
0,
);
console.log(getIdsCountById(config, 620847764)); // -> 4