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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:46:06+00:00 2026-06-05T19:46:06+00:00

I am finally asking this question as I have never actually found an answer.

  • 0

I am finally asking this question as I have never actually found an answer. If I have a javascript object with a structure such as this:

var someObj = {

    "categoryA" : {
        "func1" : function(){},
        "func2" : function(){},
    },

    "categoryB" : {
        "func3" : function(){},
        "func4" : function(){},
    }

}

func4 wants to call func2. Do I have any way of calling it without saying someObj.func2()? It seems to me this is ugly since it is ensuring the application cannot be easily renamed and appears to be more tightly coupling the internal functions. Or is this just how it is typically organised and it is not seen as a problem?

  • 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-06-05T19:46:09+00:00Added an answer on June 5, 2026 at 7:46 pm

    You can always refractor your object declaration into something that looks like this :

    var someObj = (function() {
    
        function func1(){}
        function func2() {}
        function func3() {}
    
        function func4() {
            func2();
        }
    
        var self = {
            "categoryA" : {
                "func1" : func1,
                "func2" : func2,
            },
    
            "categoryB" : {
                "func3" : func3,
                "func4" : func4,
            }
        };
    
        return self;
    }());
    

    It’s commonly called the “Module Pattern”.

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

Sidebar

Related Questions

I'm asking this question because I finally solved a problem that I have been
I have seen this question floating around the internet, but I haven't found a
I have resisted asking this seemingly n00b question, but all my recent effort to
I am thinking about asking this question from sometime.. Now I am finally asking
After a very long search I'm finally asking this question: How do I do
I understand that this question is similar to others asking about Java Properties, and
I'm asking this question for posterity reasons and general interest. Years ago I noticed
I am pretty much sure that this question have been asked and answered several
i have a quick question about objectify - this may be in the actual
I have been working on this program for a while and I finally got

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.