title: Defining read-only properties in JavaScript
body: <p>Given an object <code>obj</code>, I would like to define a read-only property <code>'prop'</code> and set its value to <code>val</code>. Is this the proper way to do that?</p>
  
  <pre><code>Object.defineProperty( obj, 'prop', {
      get: function () {
          return val;
      }
  });
  </code></pre>
  
  <p>The result should be (for <code>val = 'test'</code>):</p>
  
  <pre><code>obj.prop; // 'test'
  obj.prop = 'changed';
  obj.prop; // still 'test' since it's read-only
  </code></pre>
  
  <p>This method works btw: <a href="http://jsfiddle.net/GHMjN/">http://jsfiddle.net/GHMjN/</a><br>
  I'm just unsure if this is the easiest / smoothest / most proper way to do it...</p>