I receive an array from a JSON object. I then need to loop through the array because it contains function names that I want to execute.
The following code snippet works when entered manually:
var view_functions = [
header,
footer
];
for (i = 0; i < view_functions.length; i++) {
view_functions[i]();
}
However, in reality, the view_functions variable should be populated dynamically from the JSON data, rather than hard-coded. The JSON structure is as follows, containing an array of function names with quotes around them:
"functions" : ["header","footer"]
So, when extracting the JSON data, it is presented as an array with quotes around each element. How can I convert this structure into a usable view_functions variable without the quotes?
Thank you for your help!