I’ve looked for solutions, but couldn’t find any that work.
I have a variable called onlyVideo
.
\"onlyVideo\"
the string gets passe
If you're trying to access the property of an object, you have to start with the scope of window
and go through each property of the object until you get to the one you want. Assuming that a.b.c
has been defined somewhere else in the script, you can use the following:
var values = window;
var str = 'a.b.c'.values.split('.');
for(var i=0; i < str.length; i++)
values = values[str[i]];
This will work for getting the property of any object, no matter how deep it is.