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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:07:50+00:00 2026-06-17T03:07:50+00:00

I would like to know what is hide under some specifics ways to execute

  • 0

I would like to know what is hide under some specifics ways to execute some code.

I have 3 different ways to do in my mind, but i really don’t know which is better on what kind of situation and why.
I just choose the Case 2 method most of the time for a syntaxical preference, but i am more and more wondering what are the advantages and disadvantages of each method.

Case 1:

var response = Func();
//Handle response...

Case 2:

Func(response){
  //Handle response...
};

Case 3:

Func({
  case_x: function(opt){
    //Handle an example case...
  }
});

Thanks for the explanations i am very curious about that !

  • 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-17T03:07:51+00:00Added an answer on June 17, 2026 at 3:07 am

    Assuming that Func is an existing function:

    Case 1 is if your function returns a value and you want to store the result, such as in:

    function times_ten(num){ return num*10; }
    var ten = 10;
    var hundred = times_ten(ten);
    

    So now you can use the variable hundred from now on.

    Case 2 is if you are not returning a value, or you don’t need to save it:

    function write_times_ten(num){ num = num*10; document.write(num);  }
    var ten = 10;
    var hundred = write_times_ten(ten);
    

    Case 3 is slightly more complex.

    If you do var something={a:function(){}} – By creating an object like this, you have all of your functions in the same scope, so you don’t pollute the global namespace. This is kind of like creating a class in other languages. jQuery is the biggest example of this I can think of, because for all of what it does, it all is processed by the object jQuery (or calling a function such as jQuery.parseJSON(json_string)

    If you’re passing in an object with a function like that, then you are asking Func() to do something with that function you passed in, like so:

    function do_something_times_ten(options){
        options.num = options.num*10;
        options.do_something(num);
    }
    var ten = 10;
    do_something_times_ten({num:ten, 
                            do_something:function(num){
                                                         num = num*10;
                                                         document.write(num);  
                                                      }
                            }
    );
    

    Which would now write out 1000, not 100.

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

Sidebar

Related Questions

i would like know some reference. I know i can googling it. but prefer
I have this code i would like to know if there is a shorter
I would like to know if some one can improve my code... Using jQuery
I would like to know how to show/hide different forms based one form's selection.
I have this code and I would like to know how to set id
Would like to know how to hide an div after a set of css3
Would like to know the c# code to actually retrieve the IP type: Static
I would like to know what code to use to convert a double[] array
I would like to know how. I have looked at this topic , and
I would like to know if it's possible to process the code in a

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.