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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:01:38+00:00 2026-06-08T10:01:38+00:00

I am working through JavaScript Web Applications an want to append the class library

  • 0

I am working through “JavaScript Web Applications” an want to append the class library I created. Here is the fiddle http://jsfiddle.net/andrewjmead/gXMp8/. Right now it works, but I remember hearing it is best to avoid using __proto__ in your code. I am currently using this to create functions to manipulate private variables.

Right now the Cat class inherits from the Animal class. I want to add a private variable “name” in the constructor for cat and then create a getName and setName to manipulate this value for each instance.

Var tom = Cat("tom");
tom.setName("fud");
tom.getName(); //fud

Should I be using this.getName() instead of this.proto.getName(), or am I wrong altogether?

  • 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-08T10:01:39+00:00Added an answer on June 8, 2026 at 10:01 am

    I think in dynamic languages like javscript, or Python, there are no needs for really private variables. When we say something private, we actually say “Don’t touch this stuff if you don’t know what you are doing”. So don’t be too strict about the private thing. And, if you really want to keep some variables private, I prefer using closure. it is a good approach to make some variable really private. For example:

    function Cat(name){
        var _name = name;
    
        this.getName = function(){
            return _name;
        }
    
        this.setName = function(name){
            _name = name;
        }
    }
    

    In this approach, there is no way to access the _name variable out of Cat. But there are drawbacks you can easily figure out, that you have to write your getter and setter methods inside of constructor function. The fancy Cat.prototype.someFunc declaration gone.

    In my real work, I used to work with javascript for 2 years, I am favor of using the leading _ to tell others, this is a private variable, cause I am a Python fan. 😉

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

Sidebar

Related Questions

I'm working on an ASP.NET web application that uses a lot of JavaScript on
I am working on an ASP.Net web application that must print dynamically created labels
I'm pretty new to Javascript, Rails and JQuery all working together. I'm going through
I am working through the tutorials on writing custom spring namespace handlers found here:
Here's what i have : ASP.NET 4.0 Web Application Forms Authentication (Cookie Based) Here's
So, I have an odd problem. I'm working with an SQLite database through javascript
I'm working with a XAML file in a Silverlight Web application. I'm using JavaScript
Working with MVC3, Razor, Jquery, Javascript. The below code loops through and displays a
I am working on a web application project using Tapestry 5 framework/javascript. This application
I have inherited a working VB.NET 2.0 web app that has several User Controls

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.