An object where each key is derived from the key function and each value is the corresponding (last) element from the array.
This function is useful when you want to group elements by a key but you know that each element can only appear once per key, or when you only care about the most recent value for each key.
Unlike a traditional groupBy() function which returns an array of values
for each key, this function returns a single value per key. If multiple
elements produce the same key, only the latest (last) element in the array
will be retained.
Groups elements of an array by a key derived from each element, keeping only the last occurrence of each key.