title: How does naming an anonymous function in JavaScript make a difference?
body: <p>I am analyzing the following two urls from John Resig's site, but I am not understanding how giving a name to the anonymous function has made a difference.</p>
  
  <p>My understanding is that the name given to an anonymous function can only be used inside the function definition, and nowhere outside of it, but in the following links it is making a huge difference</p>
  
  <ul>
  <li><a href="http://ejohn.org/apps/learn/#13" rel="nofollow">http://ejohn.org/apps/learn/#13</a></li>
  <li><a href="http://ejohn.org/apps/learn/#14" rel="nofollow">http://ejohn.org/apps/learn/#14</a></li>
  </ul>
  
  <p>Any explanation or reference will be a great help.</p>
  
  <p>I am still confused with the following lines in #14</p>
  
  <pre><code>var samurai = { yell: ninja.yell }; 
  var ninja = {};
  assert( samurai.yell(4) == "hiyaaaa", "The method correctly calls itself." ); 
  </code></pre>
  
  <p><p>How is Samurai.yell method still able to point ninja.yell when ninja is now pointing to a blank object. </p> <p>Only difference between #13 and #14 is providing a name to the function expression in #14. </p> <p>Is ninja.yell COPIED to yell and NOT referenced or these kind of NAMED function expression have global scope in some scenario's like this ? 
  <Blockquote></p>
  
  <p>Same thing happens in #13 and #14, only difference is that function is named in #14 and unnamed in #13 plus ninja = {} in #14 and ninja = null in #13. Is there any hidden concept about NAMED FUNCTION EXPRESSIONS that I am missing which makes #14 workable and #13 not workable.</Blockquote></p>