How To Run Functions Referenced In A Javascript Dictionary
First we'll initialise a simple object/dictionary with some 2 key/value pairs.
const dict = {
text: 'Hello',
action: 'fun'
}
Now on the the actual fun
function. We'll declare it...
const fun = (text) => {
alert(text);
}
Pull the key/value pairs from the dictionary and store them as variables.
let text = dict.text;
let action = dict.action;
Release the hounds.
window[action](text);
Thanks for reading. x
Resources
- Javascript: https://www.javascript.com/
- A keyboard: