<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lambda calculus &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/lambda-calculus/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>What make JavaScript closures work?</title>
		<link>/2010/03/09/what-make-javascript-closures-work/</link>
		<comments>/2010/03/09/what-make-javascript-closures-work/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 07:48:21 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[Anonymous function]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Closure]]></category>
		<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[Lambda calculus]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Software engineering]]></category>

		<guid isPermaLink="false">/?p=1168</guid>
		<description><![CDATA[Closures again Most of the JavaScript developer don&#8217;t even know what a JS closure is and that&#8217;s why Crockfrod is so angry. Yes, it&#8217;s true, most of the &#8220;developers&#8221; just copy and paste the code without even know how it works. OK, just in breve the closure is an anonymous function, which thus helps you &#8230; <a href="/2010/03/09/what-make-javascript-closures-work/" class="more-link">Continue reading <span class="screen-reader-text">What make JavaScript closures work?</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2009/07/08/javascript-closures-in-brief/" rel="bookmark" title="JavaScript closures in brief">JavaScript closures in brief </a></li>
<li><a href="/2011/07/28/oop-javascript-accessing-public-methods-in-private-methods/" rel="bookmark" title="OOP JavaScript: Accessing Public Methods in Private Methods">OOP JavaScript: Accessing Public Methods in Private Methods </a></li>
<li><a href="/2011/05/30/object-oriented-javascript-inheritance/" rel="bookmark" title="Object Oriented JavaScript: Inheritance">Object Oriented JavaScript: Inheritance </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Closures again</h2>
<p>Most of the JavaScript developer don&#8217;t even know what a JS closure is and that&#8217;s why Crockfrod is so angry. Yes, it&#8217;s true, most of the &#8220;developers&#8221; just copy and paste the code without even know how it works. OK, just in breve the closure is an anonymous function, which thus helps you define a pseudo namespace, as you may know that in a function everything is visible inside it and only there.</p>
<pre lang="javascript">function myFunc() {
    var a = 10;
}
</pre>
<p>The code above makes the variable a to be visible only inside the function. But as you know there must be a function call to make &#8220;all this code work&#8221;.</p>
<pre lang="javascript">myFunc();
</pre>
<p>However you can make an anonymous function &#8211; or a closure, where the function is with no name and is called once the code has been processed. The right syntax is like so:</p>
<pre lang="javascript">
(function() { var a = 10; })();
</pre>
<h2>Why and how?</h2>
<p>The question is: why and how that works? Why this syntax is correct?</p>
<h2>Hint</h2>
<p>A tiny hint is that you can make the following line working:</p>
<pre lang="javascript">var myFunc = function(){ var a = 10; }();
</pre>
<p>Pay attention to this syntax and the assignment is what makes all this working.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2009/07/08/javascript-closures-in-brief/" rel="bookmark" title="JavaScript closures in brief">JavaScript closures in brief </a></li>
<li><a href="/2011/07/28/oop-javascript-accessing-public-methods-in-private-methods/" rel="bookmark" title="OOP JavaScript: Accessing Public Methods in Private Methods">OOP JavaScript: Accessing Public Methods in Private Methods </a></li>
<li><a href="/2011/05/30/object-oriented-javascript-inheritance/" rel="bookmark" title="Object Oriented JavaScript: Inheritance">Object Oriented JavaScript: Inheritance </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/03/09/what-make-javascript-closures-work/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
