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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:38:34+00:00 2026-06-02T02:38:34+00:00

For the code below, I want to use module pattern to keep the members

  • 0

For the code below, I want to use module pattern to keep the members private and access them through a getter. It is so simple there is no need to put any initialization in the constructor. Is this O.K?

/**
 *Global - in process of removing
 */

var Globals = ( function () 
{
    var globals = 
    {
        tag_array:          [],
        load_on:            0,
        current_tag:        0,             
        TIME:               4000,
        PASS:               0,
        FAIL:               1,
        NOTDEFINED:         2
    };
    var GlobalsInternal = function ( ) 
    {
    };
    GlobalsInternal.prototype.get = function( type ) 
    {
        return globals[ type ];
    };
    return GlobalsInternal;
} () );

Use

new Globals().get( 'TIME' );
  • 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-02T02:38:36+00:00Added an answer on June 2, 2026 at 2:38 am

    JavaScript doesn’t have classes.

    So no constructor-function means no constructor-function and an empty constructor-function is still a constructor-function.

    Thus, if new X is desired, then X must evaluate to a constructor-function (which is really just a function that knows how to behave in context).

    In any case, that’s “okay”. Just keep in mind that there is only one object named by globals (and it is closed over in the get function with such a name).


    (I think josh3736’s answer has merit for just a “global dump”. A globally-named object in JS is a singleton in other OO-language senses.)

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

Sidebar

Related Questions

I've got some very simple code below that I want to use as a
In the code below, I don't want to use instanceof to know the type
Using the code below, I want to keep the same menu div opened in
See code below: I want Page 1 to alert #testing... This works in C
I have the code below and I want to loop this every 5 seconds.
The code below does not work but meant to illustrate what I want to
I want to know if the code below removes all input type='text' values back
I have the code below with 3 columns. I want to have the border
I have this snippet of code below. I want to pass the value of
What i want is that each animation, from the code below, to start with

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.