Reputation: 1954
I've found here is a good explication of the difference between run-time functions and parse-time ones. Bit what i'm trying to do is something like this
var funtionName = 'functionInside';
var start = function(){
var a = function(){doSomething();}
return {functionInside:a}
};
And i want to call function 'functionInside' with the variable, something like
start.window[funtionName]()
Thanks in advance!
Upvotes: 1
Views: 238
Reputation: 536
There are couple of ways to do that depending on what you need.
Here are two examples:
var start = {
functionInside : function(){
doSomething();
}
};
start[funtionName](); //different ways to invoke
start.functionInside();
Here's another approach:
var start = function() {
this.functionInside = function() {doSomething();}
}
var s = new start();
s[funtionName](); //different ways to invoke
s.functionInside();
Upvotes: 1