Replace many values in a string based on search/replace pairs
<p>How can replace values as array by replace in javascript.</p>

<p>I want done replace numbers (for example) together. how is it?</p>

<p><code>1</code> -replace whit-> <code>11</code><br>
<code>2</code> -replace whit-> <code>22</code></p>

<p><strong>DEMO:</strong> <a href="http://jsfiddle.net/ygxfy/" rel="nofollow">http://jsfiddle.net/ygxfy/</a></p>

<pre><code>&lt;script type="text/javascript"&gt;
    var array = {"1":"11", "2":"22"}
    var str="13332";
    document.write(str.replace(array));
&lt;/script&gt;​
</code></pre>
