javascript test function
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3911690/question-on-this-javascript-syntax-what-does-this-do">Question on this JavaScript Syntax (&ldquo;What Does This Do?&rdquo;)</a>  </p>
</blockquote>



<p>in <a href="http://ejohn.org/blog/simple-javascript-inheritance/" rel="nofollow">this</a> article i found this:</p>

<pre><code>/xyz/.test(function(){xyz;})
</code></pre>

<p>i looked at this and i coudn't figure out how does the xyz passed to the invoker. so i did some similar test in the console:</p>

<pre><code>/xyz/.test(function(){xya;}) &gt; false
/xyz/.test(function(){xyz;}) &gt; true    

/xyz/.test(function(){'xya';}) &gt; false
/xyz/.test(function(){'xyz';}) &gt; true

/xyz/.test(function(){console.log('xya');}) &gt; false
/xyz/.test(function(){console.log('xyz');}) &gt; true

/xyz/.test(function(xya){}) &gt; false
/xyz/.test(function(xyz){}) &gt; true

/fuc/.test(function(){}) &gt; false
/func/.test(function(){}) &gt; true
</code></pre>

<p>it seems that the <code>.test()</code> function converts the argument to string and then does the test. so why <code>/xyz/.test(function(){xyz;})</code> used rather than <code>/xyz/.test('xyz')</code>?</p>
