I am attempting to collect the variable name of an array without pre-defining said name as a seperate string.
So if you have const someArray = ['cow', 'cheese', 'big_cow', 'big_cheese'];
Is there a way to make a new variable, say let arrayNameString
, that ends up being equal to 'someArray'
dynamically?
I noticed some partial solutions utilized mapping the keys of a newly defined object as well as Object.getOwnPropertyNames()
but I couldn't quite figure out how to translate that to my particular dynamic use-case.