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!

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();
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

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.