Skip to main content

Description

Counts the frequency of each element in a list, returning a map where keys are the unique elements and values are their occurrence counts.

Syntax

Parameters

Returns

Type: map (object) A map where each key is a unique element from the list and each value is the count of how many times that element appears. Returns an empty map if input is not an array.

Examples

Example 1: Basic Frequency Count

Output:

Example 2: Tag Analysis

Example 3: Finding Most Common Values

Example 4: Word Frequency Analysis

Notes

  • Returns empty map if input is not an array or is null
  • null and undefined values are stored with key "null"
  • All elements are converted to string keys in the result map
  • Useful for analytics, statistics, and data exploration
  • Can be combined with keys() and sorting for top-N analysis

See Also

Frequently Asked Questions

It returns a map where each key is a unique element from the input list and each value is the number of times that element appears.
Yes. The function works with any comparable data types including strings, numbers, and booleans.