1

I am trying to pass parameters to a function. I have:

function test(var1, var2, var3, var4, callBack, Scroll, punc, var5){
    codes....
}

When I call the function:

test('a','b','c','d','e');

I want 'e' to be var 5 instead of callback parameter. Is there anyway to do it?

2
  • If you call test() with those arguments, what do you want the values stored in callBack, Scroll, and punc to be? They can't come from nowhere. Commented Oct 2, 2012 at 18:43
  • What are you looking to change here? Are you looking to modify the function test so that you can call it in the way you describe? Or are you looking to modify the call to test so that it matches what the function expects? Commented Oct 2, 2012 at 18:44

2 Answers 2

5

test('a','b','c','d',null,null,null,'e');

Sign up to request clarification or add additional context in comments.

Comments

1

It really depends on your function but supposing it accepts to lack a callback you could do this :

test('a','b','c','d', undefined, undefined, undefined, 'e'); 

If it really needs a callback, do this :

test('a','b','c','d',function(){}, undefined, undefined, 'e');

Comments

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.