title: How to define getters and setters in a loop?
body: <p>I want to define setters and getters in the following way:</p>
  
  <pre><code>var myObj = {
      // this is the object that should be 
      // filled with new setters and getters
      ...
  }
  /**
  * This object contains getters and setters for myObj
  */
  var Fields = {
     param1: {defaultValue: ..., type: ..., ...}
     param2: ...
  }
  // so the following code doesn't work properly
  for (var field in Fields)
      Object.__defineGetter__(field, function() {
          // do smth
      });
  </code></pre>
  
  <p>this code leads to that all the getters are doing the same stuff 
  (corresponding to the last iteration of the for loop) </p>
  
  <p>How should I modify the code to make it work properly?</p>