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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:50:58+00:00 2026-05-22T20:50:58+00:00

im building a reasonably large JS application and i wanted to get your opinions

  • 0

im building a reasonably large JS application and i wanted to get your opinions on some of the logic.
i wanted to know if its considered bad practice to pass a parameter through a string of functions e.g.

function start(){
    var param1 = 'me';
    secondFunction(param1);
}

function secondFunction(param1){
    //i dont want to user the param in this function
    $.ajax('url',data,success(){
        third(param1);
    });
}

function third(param1){
    alert(param1);
}

i guess the alternative is to use global varialbes , as below. But in my case i already have a mass of global variables and, in my eyes, some things are not important enough to the global workings of the application.

var param1;

function start(){
    param1 = 'me';
    secondFunction();
}

function secondFunction(){
    //i dont want to user the param in this function
    $.ajax('url',data,success(){
        third();
    });
}

function third(){
    alert(param1);
}

So would you say passing parameters through more then one function is ok or should i be doing it another way?

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-22T20:50:59+00:00Added an answer on May 22, 2026 at 8:50 pm

    Actually, that’s good practice because it avoids having any global state (i.e. ideally, the behaviour of a function would only depend on its parameters).

    If you have many parameters to be passed through this way, I’d batch them together in a separate object (an ‘environment’ object) but apart from that it’s totally fine.

    Doing it this way gives you a lot of flexibility – if you want a function to operate on different data once, you’d just pass in different values, rather than changing the global state, which might affect everything else, too (Having no such global side-effects makes it very easy to parallelize functions, even though that may not be so important for JavaScript).

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

Sidebar

Related Questions

Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
I am building an application for which I need to periodically get information about
I am building a web application who's interface includes a large scatter plot to
We're building a business application using Microsoft ASP.NET MVC 3. Some views are now
We are building an application on an embedded platform that needs a reasonably high
I've always wanted to be able to get a reasonably elegant way of getting
Building a new ASP.net application, and planning to separate DB, 'service' tier and Web/UI
Building a search with some custom objects and three scopes: All , Active ,
Building an iPhone OS application that will allow users to anonymously post information to
I´m building a small application with Jquery and PHP. Jquery (index.html) adds Form Fields

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.