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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:53:34+00:00 2026-06-10T08:53:34+00:00

I am a JS newbie, reading a book Javascript Patterns for understanding. One of

  • 0

I am a JS newbie, reading a book Javascript Patterns for understanding. One of the code snippets I could see :

var myFunc = function param() {
...
...
};
myFunc.cache={};

This indicates a new property can be added by anyone outside the function body. Doesn’t this break encapsulation ? What if some other part of program keeps on adding new properties making my object creation bulky ? What if someone deletes/modifies properties defined by me ?

I don’t know if I am right in calling this a "problem". But if it is, please help with an approach to avoid this.

Thanks !

  • 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-10T08:53:36+00:00Added an answer on June 10, 2026 at 8:53 am

    JavaScript never really had any options to secure your objects but starting in ECMAScript 5 you can now freeze an object.

    var o = { a: 1, b: 2 };
    Object.freeze(o);
    console.log(o.a); // 1
    o.a = 2;
    console.log(o.a); // 1
    

    There is also a new context known as strict mode where an error can be thrown.

    function processObject(o) {
        "use strict";
        delete o.a; // throws a TypeError
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

newbie here! I am reading a code and I see the author frequently writing
Newbie here, I am reading some code, and I see sometimes the author used
I am a newbie to java script and currently reading John Resig's Pro javascript
I am an average newbie to CakePHP. While reading cookbook found Ajax form and
I am a newbie on optimization. I have been reading some reference on how
Newbie jquery: does the .css() function alter css properties of an element if the
I was reading about regular expressions (I'm a regex newbie, but want to learn
I am a newbie to Hadoop. I have been reading that HDFS is mostly
I'm reading the Pro ASP.NET MVC3 Framework book from Freeman and Sanderson and have
I'm a T-SQl and database newbie, and a little confused. In the T-SQL book

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.