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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:09:50+00:00 2026-05-26T11:09:50+00:00

If I have: var myFunction = function() { var myInner = function() { }

  • 0

If I have:

var myFunction = function() {
    var myInner = function() {
    }
}

then how do I call myFunction.myInner()?

  • 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-26T11:09:51+00:00Added an answer on May 26, 2026 at 11:09 am

    Functions are scopes in JavaScript. You cannot call a function from within a function, unless, you declare it as a method. Some have suggested that you use objects or weird patterns, which may or may not be what you want…

    If you want a “class-like” function with public/private methods and variables, do this:

    //Declare your "class"
    function Foo(specs) {
    
        //Can do whatever you want with specs
        //jQuery uses it to initialize plugin data ;)
    
        //These are examples of private variables
        var a = 1;
        var b = "b";
    
        //These are examples of public variables
        this.aa = 1;
        this.bb = "b";
    
        //This is a private method
        function Bar_Private(p0,p1) {...}
    
        //This is a public method
        this.Bar_Public = function(p0,p1) {...}
    
    }
    
    //Now to use it....
    //Create an instance
    var myInstance = new Foo();
    
    //Using it
    alert(myInstance.a);    //Reference Error
    alert(myInstance.aa);   //Alerts 1
    
    myInstance.Bar_Private(0,1);  //Reference Error
    myInstance.Bar_Public(0,1);   //Calls Bar_Public with 0 and 1 as params
    

    JavaScript does not have actual classes, but it is easiest to describe this pattern as “class-like”.

    Obviously, you can add as many public/private methods, objects, etc. as you like.

    Also note, DO NOT FORGET THE “new” OPERATOR WHEN CREATING AN INSTANCE WITH THIS PATTERN…if you do, then “this” is bound to your global space and can override other application data (name collisions).

    Hope this helps, good luck!

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

Sidebar

Related Questions

Suppose I have a function call from EF like: var result = context.myFunction(); the
Let's say I have following typed in my source file. var myFunction = function()
i have a function var myarr[] =new Object(); function myfunction(id,msg) { myarr[id,msg] } I
Let's say I have a class: var asdf = new Class({ myFunction: function ()
Let's say I have these geocoding calls: function myFunction(marker1,marker2) { var firstAddress = null;
If I have a function say: var my_function = function() { } If the
In a Django template, I have a function function show_graph(i){ $(#+i+seegraph).click(function(){ $(#+i+graph).show(); var qaa
I call my JavaScript function. Why do I sometimes get the error 'myFunction is
I have a function like this, that I would like to refactor function Myfunction(sUrl,
I have the following JS code: var Item = function () { this.property =

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.