title: object.defineProperty in loop
body: <p>At the moment I am using the following code to define getter and setters for my class:        </p>
  
  <pre><code>    Object.defineProperty(FPProject.prototype, 'name', {
          get: function() { return this.get('name'); },
          set: function(aValue) {return this.set('name', aValue);}
      });
      Object.defineProperty(FPProject.prototype, 'code', {
          get: function() { return this.get('code'); },
          set: function(aValue) {return this.set('code', aValue);}
      });
      Object.defineProperty(FPProject.prototype, 'clientName', {
          get: function() { return this.get('clientName'); },
          set: function(aValue) {return this.set('clientName', aValue);}
      });
      Object.defineProperty(FPProject.prototype, 'client', {
          get: function() { return this.get('client'); },
          set: function(aValue) {return this.set('client', aValue);}
      })
  </code></pre>
  
  <p>I thought I could optimise this code to something like this :</p>
  
  <pre><code>    var fields = ['name','code','clientName','client'];
  
      for (var i = 0; i &lt; fields.length; i ++ ) {
          Object.defineProperty(FPProject.prototype, fields[i], {
              get: function() { return this.get(fields[i]); },
              set: function(aValue) {return this.set(fields[i], aValue);}
          });
      }
  </code></pre>
  
  <p>but it doesn't work! I get no console errors, just cant set the properties... ???</p>