title: javascript property accessors
body: <p>In Javascript, it seems like using property accessors is not all that common (unlike in other OO languages such as Java for example).</p>
  
  <p>If I have a <code>Person</code> object with a name, defined as</p>
  
  <pre><code>function Person(name) {
     this.name = name;
  }
  </code></pre>
  
  <p>A person's name is not going to change, but I do want to be able to access it when needed, so I could do something like:</p>
  
  <pre><code>function Person(name) {
     var name = name;
     this.getName = function() {
        return name;
     }
  }
  </code></pre>
  
  <p>Even in a dynamic language, I think the principles of using getters and setters apply the same way they do to statically typed OO languages (e.g. encapsulation, adding validation, restricting access, etc)</p>
  
  <p>This question may get closed as subjective, but I'm curious as to why this behavior doesn't appear more often (e.g. Java developers would go crazy if everything was public).</p>
  
  <p>Is there a "standard" way to do this in javascript? I've seen <code>Object.defineProperty</code>, but not all browsers support that.</p>