JavaScript: Difference between revisions

Content deleted Content added
m I corrected an error.
Line 161:
</syntaxhighlight>
 
[[Anonymous function]] (or lambda) syntax and [[Closure (Computer Science)|closure]] example:
<syntaxhighlight lang="javascript">
function displayClosure() {
var count = 0;
return function () {
return ++count;
};
}
var inc = displayClosure();
inc(); // returns 1
inc(); // returns 2
inc(); // returns 3
</syntaxhighlight>
 
[[Variadic function]] demonstration (<tt>arguments</tt> is a special [[variable (programming)|variable]]).