Returns how many elements of elements are SameValueZero-equal to element. A set's own key, equivalence or comparator is not used, so frequency(set, x) can be 0 while set.has(x) is true.
elements
element
key
equivalence
frequency(set, x)
0
set.has(x)
true
Time: O(n).
Any iterable.
The value to count.
The count.
TypeError when elements is not iterable.
frequency(['a', 'b', 'a'], 'a') // 2 Copy
frequency(['a', 'b', 'a'], 'a') // 2
Returns how many elements of
elementsare SameValueZero-equal toelement. A set's ownkey,equivalenceor comparator is not used, sofrequency(set, x)can be0whileset.has(x)istrue.Time: O(n).