i’ve looked solutions, couldn’t find work.
i have variable called onlyvideo.
"onlyvideo" string gets passed function. want set variable onlyvideo inside function something. how can that?
(there number of variables called function, need work dynamically, not hard coded if statements.)
edit: there’s better way of doing you’re attempting do. asked on in javascript adventure. check out how javascript objects work.
a simple intro:
// create javascript object var obj = { "key1": 1 }; // assign - set "key2" 2 obj.key2 = 2; // read values obj.key1 === 1; obj.key2 === 2; // read values string, same result above // works special characters , spaces // , of course variables obj["key1"] === 1; obj["key2"] === 2; // read variable var key1str = "key1"; obj[key1str] === 1;
if it's global variable window[variablename] or in case window["onlyvideo"] should trick.
Comments
Post a Comment