regex.test(): where does it come from?
<p>I am curious about the use of the function named <em>test</em> (line 3) below:</p>

<pre><code>var pattern = /[1-9][1-9]{5}/;
var str = 'this is 248760!';
alert(pattern.test(str));
</code></pre>

<p>I saw this script in a book and there is no definition of the <code>test(str)</code> function. </p>

<p>Why does it alert <code>true</code> instead of giving an error?</p>
