1

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!

asked Nov 13, 2014 at 18:34

1 Answer 1

1

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();
answered Nov 13, 2014 at 18:53
Sign up to request clarification or add additional context in comments.

2 Comments

and if i want to know which function was call??
add conole.log or alerts in different areas so you can see. Or in chrome, add stops so you can trace the code.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.