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 6552849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:30:38+00:00 2026-05-25T12:30:38+00:00

The following seams to work, at least when tested via console, please let me

  • 0

The following seams to work, at least when tested via console, please let me know if its not the correct way of doing things:

function test1(x){
    x();
}

function test2(){
    console.log('test2 fired');
}

test1(test2);

Will result in console outputting:

test2 fired

So assuming the above is correct, how do i pass in a function name WITH parameters? Do they need to be passed in individually? Like this:

function test1(x,p,r){
    x(p,r);
}

function test2(p,r){
    console.log('test2 fired - p: '+p+' | r: '+r);
}

While the above should work, is there to pass in the parameters as part of ‘x’ rather then as individual params?

To give a bit of insight, what we are trying to do is basically if a condition is met inside “test1”, execute a function, that takes parameters. To simplify further, imagine test1 creates a DOM object, and we want to attach a onerror property to this DOM object. If this DOM objects fires onerror, invoke our ajax function, which takes parameters (url, querystring, method, etc). We are hoping on being able to do this without any intermediate functions.

Thank you kindly.

  • 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-25T12:30:38+00:00Added an answer on May 25, 2026 at 12:30 pm

    I suppose this doesn’t meet you condition on no intermediate functions, but the simple way of accomplishing this is passing an anonymous function:

    function test1(x){
        x();
    }
    
    function test2(p,r){
        console.log('test2 fired - p: '+p+' | r: '+r);
    }
    
    test1(function() { test2('someP', 'someR'); });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following code seems not to work, even though the file appears to be
I try to run the following raw query in android, it seems not work
I have the following, which doesn't work, my validation seems that it's not triggered
The following XML implementation seems to work fine: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
the following javascript function only seems to work when i have the final confirm()
Is the following always acceptable code? It seems to work, but does it consistently
Hey guys, the following snippet of jQuery code seems to work fine in Google
I'm building a collection of RESTful resources that work like the following: (I'll use
Following up from: Is this XML format correct? I've got some SQL code working
I'm using the following query to return all records where at least 2 conditions

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.