title: How do you map-replace characters in Javascript similar to the 'tr' function in Perl?
body: <p>I've been trying to figure out how to map a set of characters in a string to another set similar to the <code>tr</code> function in Perl. </p>
  
  <p>I found <a href="http://www.lemoda.net/perl/perl-js/perl-js.html">this site that shows equivalent functions in JS and Perl</a>, but sadly no tr equivalent. </p>
  
  <p>the <code>tr</code> (transliteration) function in Perl maps characters one to one, so</p>
  
  <pre><code>     data =~ tr|\-_|+/|;
  </code></pre>
  
  <p>would map </p>
  
  <pre><code>     - =&gt; + and _ =&gt; /
  </code></pre>
  
  <p>How can this be done efficiently in JavaScript?</p>