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

  • Home
  • SEARCH
  • 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 6213375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:41:08+00:00 2026-05-24T06:41:08+00:00

So heres the basic outline function x(){ // some code function y(){ //some more

  • 0

So heres the basic outline

function x(){
   // some code 
   function y(){
   //some more code
  }
}

function z(){
  // how do i call function y?
}

I tried

function z(){
   window[x][y];
} 

and

function z(){
x();y();
}

neither works!

  • 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-24T06:41:09+00:00Added an answer on May 24, 2026 at 6:41 am

    Lots of code, not much explanation.

    function x(){
       // some code 
       function y(){
       //some more code
      }
    }
    

    The above declares y inside x, so it is created as a property of x‘s variable object each time x is called. y can only be accessed from inside x unless code inside x makes it available from elsewhere.

    function z(){
      // how do i call function y?
    }
    

    To call y from inside z, it must be available on z‘s scope chain. That can be done by passing it in the function call (making it a property of z‘s variable object) or making it a property of some object on z‘s scope chain.

    If the function is to be available to both functions, it makes sense to declare it where it can be accessed by both x and z, or initialize z in such a manner that y is available. e.g.

    var z;
    var x = (function() {
      function y(){}
    
      z = function() {
            // something that calls y;
          };
    
      return function() {
        // x function body
      }
    }());
    

    In the above, x and z both have access to the same y function and it is not created each time x is called. Note that z will be undefined until the code assigning to x is executed.

    Note also that y is only available to x and z, it can’t be accessed by any other function (so y might be called a private function and x and z might be called privileged functions).

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

Sidebar

Related Questions

I've just wrote some code for a basic outline of a page. It for
I'm trying to create a Tile rendering program. Heres some basic code. Header class
So heres my problem. On the first fire of my code it works perfect
Here's the basic idea: There is a java window (main) that opens another java
Here one more basic question asked in MS interview recently class A { public
I am going to outline my workflow and I would like some suggestions on
Does anybody have a guide to this, containing code samples, tips and an outline
I have a function which I need to call for three different types, with
i am new at html5 and javascript. i have written a basic code for
Here's a basic regex technique that I've never managed to remember. Let's say I'm

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.