-6

I want to call function from variable i got success but i want to call function and also pass parameters,how to do it. please let me know.

Below i have mention function which is working without parameter.

function myfunction(){
alert("hellow world");
} 

var aa= "myfunction";  
window[aa]();   // working 


function myfunction(param){
alert(param);
}

// .....?
1
  • 1
    @Cerbrus The answer in the question of which you marked this a duplicate is what the OP says he can do already. So while this is a very poor question (OP should have at least tried the obvious), I don't think it's a duplicate of the question that you selected, as that question (and its marked answer) do not address passing parameters. Commented Nov 5, 2014 at 14:12

4 Answers 4

2

You can pass arguments to your function where you call window[aa]() like so:

function myfunction(text){
    alert(text);
} 

var aa= "myfunction";  
window[aa]("Hello Again..."); // just put any arguments in the parentheses.
Sign up to request clarification or add additional context in comments.

Comments

1

Just pass it in:

window[aa](param)

2 Comments

Really? A answer instead of a close-vote?
He only has 48k @Cerbrus, why would you think he'd know better? :/
1

Can you just put the parameter between the parentheses when you call the function?

window[aa]("Hello, world");

Comments

1

use this:

 function myfunction(param){
    alert(param);
 }

    var aa= "myfunction";  
    window[aa]('mk');

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.