Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3781728
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:58:57+00:00 2026-05-19T10:58:57+00:00

I have a function that accepts any number and kind of arguments, so no

  • 0

I have a function that accepts any number and kind of arguments, so no specific parameter has been defined. This function should call another function passing all arguments.

The problem is that I can pass “arguments” in order to include all arguments but in this case it will work like a single argument and not the way we expect arguments to work.

An example:

The main function:

function handleCall() {
   // let's call a sub-function
   // and pass all arguments (my question is how this is handled the right way)
   function callSubFunction( arguments );
}

function callSubfunction( userid, customerid, param) {
   // passed arguments are now 
   alert( 'userid = ' + userid );

   // this will not work, you have to use arguments[2]
   alert( param );
  }

The example call:

handleCall( 1029, 232, 'param01' );

Using the approach above, all arguments will be stored in “userid” as pseudo-array and items can be accessed e.g. arguments[2] but not using the parameter name “param”.

In ColdFusion, the solution for such stuff is the parameter “argumentCollection”, this way you can pass parameters stored in a structure without being converted to a single argument with the type struct containing all key/values.

How can I achieve the same with JavaScript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T10:58:58+00:00Added an answer on May 19, 2026 at 10:58 am

    You can use the .apply() method to call a function and pass the arguments as a set.

    callSubFunction.apply( this, arguments ); 
    

    The first argument will set the value of this in the allSubFunction method. I just set it to the current this value. The second is the collection of arguments to send.

    So your handleCall() function will look like:

    function handleCall() {
         //set the value of "this" and pass on the arguments object
        callSubFunction.apply( this, arguments );
    }
    

    It isn’t required that you send an Arguments object. You could send an Array of arguments if the circumstance required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that can accept any number of arguments... const getSearchFields =
I have a function that accepts a generic parameter T that is of type
I have a function that accepts a variable number of parameters: foo (Class... types);
I have a javascript function that accepts a number and performs a mathematical operation
Does Actionscript have a built-in function that accepts a number and can return a
I have a function that accepts one parameter and returns a table/resultset. I want
I have a function that accepts a class (not an instance) and, depending on
I have a function that accepts wildcard keyword parameters: def func(**kargs): doA doB How
I have a function foo that accepts a Boolean function def foo( f:(_)=>Boolean )
In .NET, the Generics Lists have a sort function that accepts IComparer or Comparison

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.