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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:28:40+00:00 2026-05-23T15:28:40+00:00

I was wondering if it was possible to call a private method from another

  • 0

I was wondering if it was possible to call a private method from another private method on Javascript. I have some code like the following:

function Balloon() {
function density( altitude, gas ) {
  /* KG/CU M */

  var gas = { 
   /* GAS DEFINATIONS - wolframalpha.com */
   "hydrogen" : .00100794,
   "helium"   : .004002602,
   "nitrogen" : .0140067,
   "methane"  : .0160425,
   "ammonia"  : .0170305,
   "neon"     : .0201791,
   "dry air"  : .0289644 
  }

  var alt = {
   /* CONSTANTS - http://en.wikipedia.org/wiki/Density_of_air#Altitude */
   "p0" : 101325,   // Sea level standard atmospheric pressure (Pa)
   "T0" : 288.15,   // Sea level standard temperature (K) 
   "g"  : 9.80665,  // Earth-surface gravitational acceleration (m/s^2)
   "L"  : 0.0065,   // Temperature lapse rate (K/m)
   "R"  : 8.31447   // Universal gas constant (mol * K)
  }

  var temperature = alt["T0"] - alt["L"] * altitude;
  var pressure    = alt["p0"] * (1 - (( alt["L"] * altitude ) / alt["T0"] )) ^ (( alt["g"] * gas[gas] ) / ( alt["R"] * alt["L"] ));
  var density     = ( pressure * gas[gas] ) / ( alt["R"] * temperature );

  return density;
 }

 function lift( altitude, gas ) {
  /* KG/CU M */

  return density( altitude, "dry air" ) - density( altitude, gas ); 
 }

 this.requiredGas = function( altitude, gas, ratio, weight ) {
  return (( weight / 1000 ) * ratio ) / lift( altitude, gas );
 }
}

and am trying to access it like:

balloon = new Balloon();
var required = balloon.requiredGas(10, "helium", 1.5, 4530);

I have seen people declare this from outside the private functions like so, but don’t know if that’s how to approach this one.

  • 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-23T15:28:41+00:00Added an answer on May 23, 2026 at 3:28 pm

    You are overriding the argument you pass into your density function with the gas array.

    See, it works fine once I rename it!

    http://jsfiddle.net/pEcMJ/

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

Sidebar

Related Questions

I was wondering if it was possible to call some F# code from php.
I am wondering if it is possible to call Python functions from Java code
Wondering if it's possible to do something like the following (I know the code
wondering if it is possible to have a javascript call inside a html bookmark
I am wondering if it is possible to call a derived class´ function from
I was wondering if it was possible to call a function inside a Perl
I was wondering if its possible to call an event or method the first
I was wondering if it is possible to call a non-life-cycle method of a
I was wondering if it's possible to have a function in a class, that
I am just wondering if it is possible to call multiple SQL scripts from

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.