Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No.</p> <p>From <a href="http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf" rel="nofollow">Standard ECMA-262 ECMAScript Language Specification </a> (12.9):</p> <blockquote> <p><strong>Syntax</strong></p> <p><em>ReturnStatement</em>:<br> <code>return ;</code><br> <code>return</code> [no <em>LineTerminator</em> here] <em>Expression</em> <code>;</code></p> <p>[...] A <code>return</code> statement causes a function to cease execution and return a value to the caller. If <code>Expression</code> is omitted, the return value is <code>undefined</code>. Otherwise, the return value is the value of <em>Expression</em>.</p> </blockquote> <p>The opposite is true, however: a <code>return</code> statement can prevent memory from being freed.</p> <p>From <a href="https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope#Preservation_of_variables" rel="nofollow">Functions and function scope - MDN # Preservation of variables</a>:</p> <pre><code>function outside(x) { function inside(y) { return x + y; } return inside; } fn_inside = outside(3); result = fn_inside(5); // returns 8 result1 = outside(3)(5); // returns 8 </code></pre> <blockquote> <p>Notice how <code>x</code> is preserved when <code>inside</code> is returned. A closure must preserve the arguments and variables in all scopes it references. Since each call provides potentially different arguments, a new closure is created for each call to <code>outside</code>. The memory can be freed only when the returned <code>inside</code> is no longer accessible.</p> </blockquote>
 

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