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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:59:49+00:00 2026-05-23T10:59:49+00:00

While I have a suspicion that there isn’t a way to make a completely

  • 0

While I have a suspicion that there isn’t a way to make a completely untouchable JSON object in a web application, I was wondering if any of you had ways to maintain a global JSON object that could not be altered using developer tools’ consoles. I know that calling this a “private” variable isn’t the most accurate description but the restrictions that a private variable in OO languages are basically what I would like to have applied to my JSON object.

I have an application that I am developing that would benefit from keeping a savvy user from interacting with the object that I’m using for storing data in the Javascript file.

Any suggestions on how to approach this would be appreciated.

  • 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-23T10:59:49+00:00Added an answer on May 23, 2026 at 10:59 am

    Actually you can have “private” variables in javascript and getter method to acces them:

    you can do:

    function privateData(){
         var _myVariable = 1;
         return {
              getData: function(){
                     return _myVariable;
               }
          }
    }
    
    var myObject = privateData();
    
    myObject._myVariable; //it's undefined
    myObject.getData();//returns 1
    

    In this example the variable _myVariable is not accessible in the browser and not modificable by the user in any way because it’s local scope is inside the function. Your function returns an object that can access that variable because, by returning an object, you create a closure.

    In this case getData is a property of the returned object and can access _myVariable because it’s local scope is that of function privateData.

    I reccomend the books:

    • Object Oriented Javascript and Javascript patterns by Stojanov
    • Javascript: the good parts by Crockford

    for some advanced javascript tecniques

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

Sidebar

Related Questions

There are customers that want to customize to brand my product, while have me
I've been doing web development for a while and have yet to read a
While I have played with parts of Qt in the past I am thinking
The while loop I have while reading in from a file doesn't break. I'm
For while I have been trying to set the Page Scaling of Excel page
Its been a while I have ready Mcconnell's Code Complete . Now I read
I'm doing some homework and while I have some experience with SML, Haskell has
If I do an svn update while I have Visual Studio open and a
I've been thinking about this problem for a while and have yet to come
I am making a fighting game in Flash and while I have everything running,

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.