Simple JavaScript String.replace.call results in "InternalError: too much recursion"
<p>Given the following JavaScript "class" definition:</p>

<pre><code>var Quota = function(totalMinutes){
    this.totalMinutes = parseInt(totalMinutes || 0, 10);
};

Quota.prototype.valueOf = function(){
    return this.totalMinutes;
};

Quota.prototype.toString = function(format){
    format = format || "hh:mm";

    return format.replace.call(this, /hh?|mm?/g, function(match){
        switch (match) {
            case "hh":
                return this.totalMinutes * 60;
            case "mm":
                return this.totalMinutes;
        }
    });
};
</code></pre>

<p>Can you please explain exactly why the below call to <code>toString()</code>...</p>

<pre><code>var q1 = new Quota(60);
console.log( q1.toString() );
</code></pre>

<p>...results in the following error being raised:</p>

<blockquote>
  <p><strong>InternalError</strong>: too much recursion {
  message="too much recursion", 
  more...}</p>
</blockquote>

<p>I'm running the code (Firefox 3.5.7 + Firebug 1.5) in the Firebug Console.  Ideally I'd like to know where is the recursive call back to <code>toString()</code> and your suggestions for how the replace function could be executed here via <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Function/call" rel="nofollow"><code>call</code></a> or <a href="https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/Function/Apply" rel="nofollow"><code>apply</code></a></p>
