In my configuration file, I have TypeScript data like this:
const filtersTracking = {
[SEARCH_TYPE_ARTICLES]: {
orderBy: {
category: 'Search Filter Legal Tips',
action: 'Sorting Selection',
},
practiceAreas: {
category: 'Search Filter Legal Tips',
action: 'Practice Area Selection',
},
ratingAverage: {
category: 'Search Filter Legal Tips',
action: 'Star Rating',
},
ratingCount: {
category: 'Search Filter Legal Tips',
action: 'Number of Ratings',
},
publicationYear: {
category: 'Search Filter Legal Tips',
action: 'Publication Year',
},
isGuide: {
category: 'Search Filter Legal Tips',
action: 'Guide',
},
hasVideo: {
category: 'Search Filter Legal Tips',
action: 'Video',
},
internationalLaws: {
category: 'Search Filter Legal Tips',
action: 'International Law',
},
},
}
I am trying to extract the 'category' and 'action' data using different methods but none seem to work:
- filtersTracking[SEARCH_TYPE_ARTICLES][key]
- filtersTracking[SEARCH_TYPE_ARTICLES].key
- filtersTracking[SEARCH_TYPE_ARTICLES].[key]
The variable 'key' dynamically holds the data key (e.g., 'orderBy' or 'practiceArea').
public function(key) {
console.log(filtersTracking[SEARCH_TYPE_ARTICLES][key])
}