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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:43:19+00:00 2026-05-26T15:43:19+00:00

i am very new in jquery. so i was searching google for jquery callback

  • 0

i am very new in jquery. so i was searching google for jquery callback function and i got a code but i did not understand the flow of the code. so please anyone help me to understand the coding flow.

here is the code

function mightyplugin(foo, callback){
// big code block here

   callback.apply(this, [foo]);
}

mightyplugin("Bar!", function(param){
    alert(param);
});

here i am passing "Bar!" as one argument to function mightyplugin and a anonymous function.

  1. what callback.apply does. what this keyword will hold actually…. why it is required.
  2. why [foo] is passed as array.
  3. what would be the syntax if i pass many argument like

    mightyplugin("Bar!","1stone","2ndone", function(param){
        alert(param);
    });
    

i know callback function invoke when first function finish but here situation is different… why?

please explain…
thanks

  • 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-26T15:43:19+00:00Added an answer on May 26, 2026 at 3:43 pm

    First of all, this isn’t jquery. This is an example of how to deal with callback functions yourself, independent of jquery.

    To answer your qestions:

    1. Details on apply can be found here: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/apply
    2. As you’ll see if you read the above link, the 2nd parameter passed to apply is an array of arguments.
    3. I’m not sure what your intent is for those other parameters, but you can simply add more parameters to your function:

    function mightyplugin(foo, foo1, foo2, callback){
       // big code block here
    
       callback.apply(this, [foo, foo1, foo2]);
    }
    
    mightyplugin("Bar!","1stone","2ndone", function(param){ alert(param); });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new on jquery, today i tried this following code $(#new).click(function() {
How do you make this code shorter, i'm very new to jquery but i
I'm very new to jquery and programming in general but I'm still trying to
I'm very new to JQuery, but I was told the one of the cool
I am loading images externally using jQuery load function.. but not able add light
hai i am very new to jquery and jqgrid.. i have implemented a grid...but
REVISED CODE AT THE END I'm very new to jquery, and even though I
i am very new at jquery and code, here i am trying to get
I'm very new to jQuery but keen to learn. Because of this I'm using
I am very new to JQuery but already like it a lot. I am

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.