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

  • Home
  • SEARCH
  • 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 8855097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:03:07+00:00 2026-06-14T14:03:07+00:00

function outerFun(arg1, arg2, arg3){ function innerFun(arg1, arg2){ //do something } var innerArgs = Array.prototype.slice.call(arguments,

  • 0
function outerFun(arg1, arg2, arg3){

    function innerFun(arg1, arg2){
        //do something
    }

    var innerArgs = Array.prototype.slice.call(arguments, 1);
    innerFun.apply(null, innerArgs);
}

As you can see i’m trying to call a function with a modified arguments array of a different function. The only way of doing this i can think of is using the apply() method and passing the sliced array. My question is, is there a different way of doing this? If there isn’t then can i just pass null to apply() or is that considered bad practice?

  • 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-06-14T14:03:08+00:00Added an answer on June 14, 2026 at 2:03 pm

    My question is, is there a different way of doing this?

    No, apply() is the only method in JavaScript capable of running a function with an array as arguments. However, you could still use the actual arguments and use the function:

    function outerFunc(arg1, arg2, arg3){
        /* ... */
        innerFun(arg2, arg3);
        /* ... */
    }
    

    If there isn’t then can i just pass null to apply() or is that considered bad practice?

    You can, and it’s not considered bad practice. The function behaves just as if you use it in a global context. This also enables you to use arrays on functions which take several arguments.

    See also:

    • MDN: apply(): apply and built-in functions
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); return
function test() { alert(Array.join.call(arguments,'/')) //alerts / alert(Array.prototype.join.call(arguments,'/')) //alerts Js/JScript alert(Array.join(arguments,'/')) //alerts Js/JScript } test('Js','JScript');
function something(frm,i){ //var ch=frm.outof1.value; for(var j=1;j<=i;j++) { //var b=outof + j; alert(frm.outof+j.value); } //alert(outof
function checkuser(user) { var ret = false; $.ajax({ type:'POST', url:'user.php', async:false, data:{'user':user}, success:function (data)
function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = http://localhost/index.php?nph-psf=0&HOSTID=AD&ALIAS= + WinNetwork.UserName;
function killsession() { // global $_SESSION; $_SESSION = array(); if (session_id() != || isset($_COOKIE[session_name()]))
function Person() {} Person.prototype.population = 0; Person.prototype.constructor = function(name) { this.name = name; console.log(Name:
function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = createCustomURL(WinNetwork.UserName); document.getElementById(psyncLink).src =
function ff_chk_username_unique(element, action) { alert(element.value); alert(action); var actiona=http://localhost/myproject/check/check_username.php; var form_data = { username: element.value,
function log(tobelogged){ if (debugging){ c.log(arguments); c.log(arguments.toString()); c.log(tobelogged); }; }; and then log(someObject); and I

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.