function f1 () {
console.log('f1')
}
var s = 'f1'
runLocalFunctionByName(s)
Is this possible at all to write runLocalFunctionByName()
or just call f1
without typing f1
in the source code, but using a variable holding its name? I mean without modifying f1
into a method, that answer is obvious: just make myobj.f1 = function
or declare it globally like f1= function()
. I am talking about normal local functions declared with function
keyword only, not as vars, global vars or some other object property.