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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:44:56+00:00 2026-05-22T02:44:56+00:00

I have a little quandary over whether it is good practice to do the

  • 0

I have a little quandary over whether it is good practice to do the following.

I have a global object literal or namespace that I use to contain base functions and variables.

Within this I have a Page property which contains all the variables and functions for a specific page. I also contain references to element IDs in a property within the Page property. This is due to having an ASP.NET site whereby I need to store the .NET-generated client IDs so I can reference them with jQuery.

Base
    Base.Page
        Base.Page.Elements

My issue is that I find myself assigning “shortcut” variables to these literals within my page functions such as the following:

Base.Page.DoThisStuff = function () {
    var p = Base.Page;
    var pe = Base.Page.Elements;

    //Function Stuff Here

    p = null;
    pe = null;
}

My question is: Is it a better idea to create a ‘global’ variable in my master page, such as var _p = Base.Page; or is this horrible and bad practice and I should continue as above?

(My namespaces don’t have names as short as the above – they are just for illustration.

I have not tagged ASP.NET or jQuery as I don’t think they directly relate to this question.)

  • 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-22T02:44:57+00:00Added an answer on May 22, 2026 at 2:44 am

    This really seems to me a question of programming style, and each answer will vary.

    I would keep my variables in as smaller a scope as possible, hence, I would prefer the solution above rather then the global variables shortcuts idea.

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

Sidebar

Related Questions

i have little dilemma, i often use data-bound controls such as Gridview in conjunction
I have little Silverlight app that needs to make queries to server, is it
I have little problem. I can't use AcceptVerb.Get on some ASP.NET MVC actions because
I have little notification divs that should appear above the navigation. I tried other
I want to make a game where you have little avatars walking over pages,
I have little working knowledge of python. I know that there is something called
I have little problem that I have been trying to solve for some time.
I have little problem with fancybox jquery library. when I use this simple line
I have little unusual problem to solve. I need some hint or links to
I have little bit longer question for you - but hope answer will be

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.