<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: horiyorrmi72</title>
    <description>The latest articles on DEV Community by horiyorrmi72 (@horiyorrmi72).</description>
    <link>https://dev.to/horiyorrmi72</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F310771%2Fb0987f48-abdf-4cce-919d-d11b404de007.png</url>
      <title>DEV Community: horiyorrmi72</title>
      <link>https://dev.to/horiyorrmi72</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/horiyorrmi72"/>
    <language>en</language>
    <item>
      <title>function of function &amp; closure</title>
      <dc:creator>horiyorrmi72</dc:creator>
      <pubDate>Mon, 18 Sep 2023 20:28:20 +0000</pubDate>
      <link>https://dev.to/horiyorrmi72/function-of-function-closure-56m2</link>
      <guid>https://dev.to/horiyorrmi72/function-of-function-closure-56m2</guid>
      <description>&lt;p&gt;A "function within a function" and a "closure" are related concepts, but they have distinct differences:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Function within a Function:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This refers to a function that is defined inside another function.&lt;/li&gt;
&lt;li&gt;The inner function can access variables and parameters of the outer function, but it does not necessarily create a closure.&lt;/li&gt;
&lt;li&gt;The inner function can be invoked only within the scope of the outer function.&lt;/li&gt;
&lt;li&gt;Once the outer function finishes executing, the inner function's access to the outer variables may be lost.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Closure:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A closure is created when an inner function "closes over" its surrounding lexical (scope) environment, capturing and retaining access to variables even after the outer function has finished executing.&lt;/li&gt;
&lt;li&gt;Closures allow the inner function to access and "remember" the variables of its outer function, even outside the outer function's scope.&lt;/li&gt;
&lt;li&gt;Closures are not limited to being invoked only within the scope of the outer function; they can be passed around and invoked from different places, preserving access to the captured variables.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;every closure is an example of a function within a function, but not every function within a function creates a closure. A closure specifically occurs when an inner function maintains access to its enclosing scope, allowing it to access variables from the outer function even after that function has completed its execution. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>closure</category>
      <category>function</category>
    </item>
  </channel>
</rss>
