title: Create an object with modified versions of all methods in a source object
body: <p>I want to create an object that has modified versions of all of the methods in a source object, but I'm having trouble using for...in. </p>
  
  <p>If this is my source object:</p>
  
  <pre><code>var raw = {};
  raw.add = function(a,b){return a + b;}
  raw.sub = function(a,b){return a - b;}
  raw.neg = function(a){return -a;}
  raw.sqrt = function(a){return Math.sqrt(a);}
  </code></pre>
  
  <p>It works if I recreate the list of properties in an array of strings:</p>
  
  <pre><code>var mod2 = Object.create(raw);
  var proplist = ["add", "sub", "neg", "sqrt"];
  proplist.forEach(function(prop){
  
      mod2[prop] = function(){
          var arglist = [].slice.apply(arguments);
          var out = [];
          if(arglist.length == 1){
              [].concat(arglist[0]).forEach(function(d){ out.push(raw[prop](d)); });
          }
          else if(arglist.length == 2){
              [].concat(arglist[0]).forEach(function(d1){
                  [].concat(arglist[1]).forEach(function(d2){
                      out.push(raw[prop](d1,d2));
                  })
              });
          }
          return out;
      }
  });
  </code></pre>
  
  <p>But my attempt to use for..in doesn't work, all of the methods in the new object will do "sqrt":</p>
  
  <pre><code>var modified = Object.create(raw);
  for(prop in raw){
  
      modified[prop] = function(){
          var arglist = [].slice.apply(arguments);
          var out = [];
          if(arglist.length == 1){
              [].concat(arglist[0]).forEach(function(d){ out.push(raw[prop](d)); });
          }
          else if(arglist.length == 2){
              [].concat(arglist[0]).forEach(function(d1){
                  [].concat(arglist[1]).forEach(function(d2){
                      out.push(raw[prop](d1,d2));
                  })
              });
          }
          return out;
      }
  }
  </code></pre>
  
  <p>What is the best way to iterate through the methods automatically?</p>