Is there a way to get an object using the object name (also given from a function variable)?
I’m saying if you give a variable as function input, is there a way to get the object with the variable name?
I don’t know if I explained myself well.
See the code sample to be more exhaustive:
function testFunction(objectname_as_string){
objectname_as_string.property = 'value'; //this is not working well because this way it's like assigning a property to a string
}
In this case if you want an object called ‘animal’ do:
testFunction('animal'); //it doesn't work for the reason explained in the code comment above
So how to get a object from a string with object name and then work on the object with the given variable name?