JS array count elements

preview_player
Показать описание
How to count JS array elements?
We can use object properties to do that.
All you need are an empty object, forEach method, an arrow function and a logical disjunction operator to initiate values.
We use elements as object property names and increase its value every time we meet it.
That’s all.
Two Mashas, two Petya and single Vasya.
Рекомендации по теме