Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>What happens to abc?</p> </blockquote> <p>It contains a function object. If you are doing nothing with it, it will be garbage-collected.</p> <blockquote> <p>Why it works?</p> </blockquote> <p>Why not? What "works"?</p> <blockquote> <p>abc can be called but not def, why?</p> </blockquote> <p>This is only true from outside, and not in IE. See below.</p> <blockquote> <p>Is it a function declaration or an expression?</p> </blockquote> <p>It is a function expression. You can easily see that as it is part of an assignment expression; declarations always need to be on top level (of functions or global code)</p> <blockquote> <p>def is undefined - why? </p> </blockquote> <p>Only from outside. A function expression does not create variables. "def" is the <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/name" rel="noreferrer">name</a> of the function, and inside the function it is a reference to the function as well. This allows recursion for example without using any outer variables.</p> <pre><code>var abc = function def() { def === abc; // true def.name; // "def" } abc(); def; // undefined </code></pre> <blockquote> <p>If it is supposed to be, are there memory leaks?</p> </blockquote> <p>Yes, in Internet Explorer. It creates two distinct functions from that code. For the details, see <a href="http://kangax.github.com/nfe/#jscript-bugs" rel="noreferrer">http://kangax.github.com/nfe/#jscript-bugs</a></p> <blockquote> <p>Why is abc.prototype is function def?</p> </blockquote> <p>It is not. It is just an object. Maybe it is shown with that name in your console, as belongs to a function named "def".</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload