title: How can I pipe functions in JS like Elm does?
body: <p>I'm just getting into functional programming and i'm having a hard time figuring out how to do this (if it's even worth the trouble). I've looked into currying and am not sure if this is the direction I need to go?? Or pipelines?</p>
  
  <p>I would like to start with a value and then pipe it through different functions. Underscore has the 'chain' method which is similar. However I don't want to use prototypes to do this. I realize the solution might not match my target syntax.</p>
  
  <p>Elm has the <code>|&gt;</code> syntax (below) which is really nice to look at</p>
  
  <pre><code>// what i'd like to do (or similar) in JS *without using prototype*
  num = ("(123) 456-7890")
    .removeDashes()
    .removeParens()
    .removeSpaces()
  
  // what elm does
  "(123) 456-7890"
    |&gt; removeDashes
    |&gt; removeParens
    |&gt; rem
  
  
  // functions I wrote so far
  
  removeDashes = function(str) {
    return str.replace(/-/g, '');
  };
  
  removeParens = function(str) {
    return str.replace(/\(|\)/g, '');
  };
  
  removeSpaces = function(str) {
    return str.replace(/\s/g, '');
  };
  
  
  // what i'm currently doing
  
  num =
    removeDashes(
      removeParens(
        removeSpaces(
          "(123) 456-7890"")));
  </code></pre>