title: Function to transform methods into functions that take this as their first argument
body: <p>The initial problem was splitting a string using a delimiter in JS and then removing whitespace from both sides of each result. The solution to this looked like this:</p>
  
  <pre><code>var mystring = "First thing, Second thing";
  var things = mystring.split(",").map(function(s) { return s.trim(); });
  // things is now ["First thing", "Second thing"]
  </code></pre>
  
  <p>This made me think if there's a way to write this without creating an anonymous (or named) function to contain trim. How do I write a function <code>unmethod</code> such that</p>
  
  <pre><code>mystring.split(",").map(unmethod(String.prototype.trim));
  // returns ["First thing", "Second thing"]
  </code></pre>
  
  <p>returns an array that is the same as <code>things</code>. In other words, how do I transform some method that expects <code>this</code> to be bound into a function that takes one variable and operates on that variable the same way the method would on <code>this</code>.</p>
  
  <p>Also, what if I wanted to pass arguments to the method? For example, if I wanted to map <code>split</code> over an array of strings I'd need a way to pass it the delimiter.</p>