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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:42:05+00:00 2026-06-13T13:42:05+00:00

As Douglas Crockford says we can have private properties using closures in JavaScript and

  • 0

As Douglas Crockford says we can have private properties using closures in JavaScript and they are very handy to handle secure data.

Now I understand the concept of Encapsulation, as it helps us to manage and structure the code . Even private variables are useful for performance, eg: you can cache DOM elements, properties and global variables for iterative access.

So the question is: How exactly closures or private variables help us in handling the sensitive data?

  • 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-13T13:42:06+00:00Added an answer on June 13, 2026 at 1:42 pm

    You can secure the data of a certain component of your code against the rest of the code. Or maybe any third party scripts you might have included in your page. So you can protect any sensitive intermediate data from being exploited through XSS attacks.

    While any data that is present in DOM (say in input elements) is accessible to any script in the page. However some variable in javascript can be closed inside a closure scope making it virtually inaccessible by any other script.

    
    x = {}
    (function(){
        var a;
    
        x.fn = function(arg){
            a = arg;  // Can access and modify a;
        }
    
    })();
    
    function fn2(){
        a = 12; // This does not change the a above;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Douglas Crockford himself says so ! http://www.crockford.com/javascript/javascript.html I have been working with JS only
I'm currently using a JavaScript coding style based on Douglas Crockford's Code Conventions for
I'm reading Douglas Crockford's book JavaScript: The Good Parts. I can't understand the sentence
I read here (Douglas Crockford) using prototype operator to add methods to Javascript classes
Douglas Crockford says: JavaScript is a sloppy language, but inside it there is an
I'm using Douglas Crockford's design pattern to implement private, privileged and public methods. It
I know you can achieve something as privateness in JavaScript by using closures and
In an article on yuiblog Douglas Crockford says that the for in statement will
In Douglas Crockford's JavaScript: The Good Parts he recommends that we use functional inheritance.
I just started reading on Douglas Crockford's Javascript The Good parts where he explains

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.