* Calculates the frequency of each unique element in an array.
* @templateT - The type of elements in the array, which extends string or number.
* @param{T[]}arr - An array of elements of type T.
* @returns{Record<T, number>} - An object where the keys are the unique elements from the input array and the values are their corresponding frequencies.