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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:00:24+00:00 2026-06-16T11:00:24+00:00

I use to enjoy using js. Now I am just frustrated. I am trying

  • 0

I use to enjoy using js. Now I am just frustrated. I am trying to jsDoc a large chunk of code that was purchased by my boss. The author did not provide an API so I am going to create one using jsDoc.

Unfortunately the code is not clear and it contains about 10k lines of code in one js file. I have used object literals in the past, this is not an object literal. The parameters and functions are not separated by commas. Additionally, a prototype is never used, but the new operator is. I have looked in several books and namespacing appears to be the closest ‘style’. Here is the generic flow of the program. My questions follow the example.

(function () {
var global = (function () {return this; } ).call();
global.X = {};
})();

X.init = function(){
    X.MyObjectA = new X.FooA();
    X.MyObjectB = new X.FooB();
}

X.FooA = function() {
   var storeStuff;
   do stuff
   .
   .
   function bar(){
        var storeSomething;
        do something
        do somthing else
        .
        .
        moreFunctions(){}
        var moreVars;
        .
        .

    }

    this.anOccasionalFunctionLiteral = function(){}
        .
        .
}

X.FooB = function(){
    Similar contents of FooB()
 }
 .
 .
 .
 Continues forever...

So my questions are:

  1. What style is this!? When I say style I guess I really mean what are FooA and FooB? Are they objects? Classes?

  2. What title should I give the nested functions if they aren’t members of X.FooA or X.FooB. I have been told nested functions, including bar(), are not methods of objects FooA and FooB.

  3. If the function nested inside of the object is in fact not a method of its surrounding object can it be called from anywhere? Or do normal scope rules apply?

To make life more readable and happy I have been classifying objects similar to FooA and FooB as constructors and any methods inside of the constructors, such as bar(), as methods of FooA and FooB. This may not be correct but at least it’s organized. Any suggestions?

Thanks for your help!

  • 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-16T11:00:25+00:00Added an answer on June 16, 2026 at 11:00 am

    FooA and FooB are constructor functions.

    The nested functions are “private” functions.

    The bar function inside of FooA can only be called inside FooA.

    See
    http://javascript.crockford.com/private.html

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

Sidebar

Related Questions

I use both ruby on rails and Java. I really enjoy using migrations when
I've been tinkering with the GAE and I enjoy the ease of use of
I enjoy using recursion whenever I can, it seems like a much more natural
I am using this code to make a Simple Command: public class SimpleCommand :
I've begun using ReSharper and really enjoy it. However I have a project which
I'm trying to protect page by making a member only area the code I
I have decided to use SubSonic (v3.0) for the first time and thoroughly enjoy
I do some hobby work with PIC Microcontrollers and I really enjoy using them
I'm learning the use of the switch statement and using the rand() and srand()
Corporate networks use AD mostly to authenticate users - in that desktop machines require

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.