<?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: Mohammad Al Hallaq</title>
    <description>The latest articles on DEV Community by Mohammad Al Hallaq (@mohmmadalhallaq).</description>
    <link>https://dev.to/mohmmadalhallaq</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F729289%2F97d93cd5-71a9-4aea-b803-db0cb3a15778.jpeg</url>
      <title>DEV Community: Mohammad Al Hallaq</title>
      <link>https://dev.to/mohmmadalhallaq</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohmmadalhallaq"/>
    <language>en</language>
    <item>
      <title>simple example of Closures in JavaScript</title>
      <dc:creator>Mohammad Al Hallaq</dc:creator>
      <pubDate>Mon, 18 Oct 2021 15:20:25 +0000</pubDate>
      <link>https://dev.to/mohmmadalhallaq/simple-example-of-closures-in-javascript-4f3h</link>
      <guid>https://dev.to/mohmmadalhallaq/simple-example-of-closures-in-javascript-4f3h</guid>
      <description>&lt;p&gt;&lt;strong&gt;Closures&lt;/strong&gt; are a fundamental and powerful property of Javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//we have an outer function named walk and an inner function named fly

function walk (){

  var dist = '1780 feet';

  function fly(){
    console.log('At '+dist);
  }

  return fly;
}

var flyFunc = walk(); //calling walk returns the fly function which is being assigned to flyFunc
//you would expect that once the walk function above is run
//you would think that JavaScript has gotten rid of the 'dist' var

flyFunc(); //Logs out 'At 1780 feet'
//but you still can use the function as above 
//this is the power of closures
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
