Implement a uniqBy function that returns a new array with duplicate values removed, where uniqueness is determined by the result of applying an iteratee function to each element.
1. Basic Functionality
Accept an array and an iteratee (function or property name string)
Remove duplicates based on the iteratee's return value
Keep the first occurrence of each unique iteratee result
Preserve the original order of elements
2. Iteratee Types
If iteratee is a function, call it with each element
If iteratee is a string, use it as a property key
Examples
// Function iterateeuniqBy([2.1,1.2,2.3],Math.floor);// Returns: [2.1, 1.2] (2.1 and 2.3 both floor to 2)// Property string iterateeuniqBy([{id:1,name:'a'},{id:2,name:'b'},{id:1,name:'c'}],'id');// Returns: [{ id: 1, name: 'a' }, { id: 2, name: 'b' }]
Constraints
Return a new array (do not mutate the original)
Keep the first occurrence when duplicates are found