Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>Updated to include caveats in the comments below from</em> <a href="https://stackoverflow.com/users/5445/cms">CMS</a>, <a href="https://stackoverflow.com/users/96100/tim-down">Tim Down</a>, <a href="https://stackoverflow.com/users/375394/moogoo">MooGoo</a>:</p> <p>The closest thing available to what you're after is calling <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Object/toString" rel="noreferrer"><code>.toString()</code></a> on a function to get the full function text, like this:</p> <pre><code>function derp() { a(); b(); c(); } alert(derp.toString()); //"function derp() { a(); b(); c(); }" </code></pre> <p><a href="http://jsfiddle.net/nick_craver/F4pvf/" rel="noreferrer">You can give it a try here</a>, some caveats to be aware of though:</p> <ul> <li>The <code>.toString()</code> on function is <em>implementation-dependent</em> (<a href="http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%203rd%20edition,%20December%201999.pdf" rel="noreferrer">Spec here</a> section <strong>15.3.4.2</strong>) <ul> <li><em>From the spec:</em> An implementation-dependent representation of the function is returned. This representation has the syntax of a <em>FunctionDeclaration</em>. Note in particular that the use and placement of white space, line terminators, and semicolons within the representation string is implementation-dependent.</li> <li>Noted differences in Opera Mobile, early Safari, neither displaying source like my example above.</li> </ul></li> <li>Firefox returns a compiled function, after optimization, for example: <ul> <li><code>(function() { x=5; 1+2+3; }).toString()</code> == <code>function() { x=5; }</code></li> </ul></li> </ul>
    singulars
    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. 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.
    3. 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