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

The Archive Base Latest Questions

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

Sorry for fuzzy post title, I can’t formulate the correct name in English for

  • 0

Sorry for fuzzy post title, I can’t formulate the correct name in English for this post.

For example I have such an object:

var APP = {
    a : 1,
    b : function(){
        return this.a;
    }
}

In such way, if I call console.log ( APP.b() ) than this will be referring to APP and result will be 1.

But how to connect to APP from sub-object?
Example:

var APP = {
    a : 1,
    b : function(){
        return this.a;
    },
    c : {
        c1: function(){
             return APP.a;
        }
    }
}

console.log ( APP.c.c1() ) // 1

This example works, but it’s bad idea to point directly to APP. For example:

APP2 = APP;
APP = null;
console.log ( APP2.b() );  // 1
console.log ( APP2.c.c1() ); // APP is undefined

UPD:

I’ve got half-decision:
if I declare property c like a method:

c : function(){
    var self = this;
    return {
        c1: function(){
            return self.b();
        },
        c2: function(){}
    }
}

It will work, but I should call a method but not property (too much brackets) :

console.log( APP2.c().c1() ) instead of console.log( APP2.c.c1() )

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

    You can create a factory method:

    var APP = (function(){
       var self;
       return self = {
          a : 1,
          b : function(){
              return this.a; // could be self, only differs in non-context use
          },
          c : {
              c1: function(){
                   return self.a;
              }
          }
       };
    })();
    
    APP2 = APP;
    APP = null;
    APP2.b();  // 1
    APP2.c.c1(); // 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for this simple question, but I can't solve it... There is an example:
(sorry about the long title) I have a custom object Person, which in turn
Sorry if the title is not clear enough, I have <a> elements with the
Sorry if this is stupid question, but I'm new to MATLAB. I have a
Sorry this is such a long question. Ive been doing lots of research lately
Sorry, My English is not good, I have a View: <div class=editor-field id =
(Sorry about the title, couldn't think of how to explain it) So I have
Sorry for the double post: a friend of mine asked this on the mailing
Sorry the title isn't more help. I have a database of media-file URLs that
Sorry if the title is poorly descriptive, but I can't do better right now

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.