In order to retrieve an object based on two arrays, the first consisting of unique values and the second containing any values, where the key represents a word and the value indicates the frequency of matches for that word, follow these steps:
For instance:
let uniqueArray = ['green', 'blue', 'red'];
let anyArray = ['red', 'green', 'red', 'blue, 'yellow', 'green', 'pink', 'red'];
The result will be:
{'green': 2, 'blue': 1, 'red': 3}