title: Clarifying Javascript Object.defineProperties usage
body: <p>I still don't feel like I completely understand the use of Object.defineProperties, so I'd appreciate some input on the following (somewhat contrived) examples:</p>
  
  <hr>
  
  <h2>1. <code>my_val</code> behaves the same for <code>one</code> and <code>two</code> in the following code:</h2>
  
  <pre><code>var Class_1 = function (arg) {
      this.my_val = arg;
  };
  
  var Class_2 = function (arg) {
      Object.defineProperties(this,{
          my_val : {
              value : arg,
              writable : true,
              enumerable : true,
              configurable : true
          }
      });
  };
  
  var one = new Class_1("foo");
  var two = new Class_2("foo");
  </code></pre>
  
  <p>And the reasoning for using <code>defineProperties</code> over just assigning it like in Class_1 would be when you want <code>writable</code>, <code>enumerable</code> or <code>configurable</code> to be false; Basically it's for control. Otherwise the simple <code>this.property</code> definition is identical, correct?</p>
  
  <hr>
  
  <h2>2. <code>my_val</code> behaves the same for <code>three</code> and <code>four</code> in the following code:</h2>
  
  <pre><code>var Class_value = function (arg) {
      Object.defineProperties(this, {
          my_val : {
              value : arg, 
              writable : true,
  //          enumerable : false   // default
  //          configurable : false // default
          }
      });
  };
  
  var Class_getSet = function (arg) {
      Object.defineProperties(this, {
          __my_val : {
              value : arg,
              writable : true,
  //          enumerable : false   // default
  //          configurable : false // default
          },
          my_val : {
              get : function(){ return this.__my_val; }, 
              set : function(new_val){ this.__my_val = new_val; }
          }
      });
  };
  
  var three = new Class_value("foo");
  var four = new Class_getSet("foo");
  </code></pre>
  
  <p>And the reasoning for using <code>get</code>/<code>set</code> functions over just <code>value</code> would be when you want to add more advanced logic, like calling another function when <code>my_val</code> is updated, or sending an event, etc. Also you cannot use <code>get</code>/<code>set</code> without at least defining the initial value (either via a <code>value</code> property shown here, or via the simple <code>this.property = ...</code> definition as in <strong>1.</strong>), correct?</p>
  
  <hr>
  
  <p>Basically I'm just looking to make sure that I understand the reasoning for how and when to use defineProperties, since I feel like I don't have a good handle on the concept yet.</p>