<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dorababu Arigi on Medium]]></title>
        <description><![CDATA[Stories by Dorababu Arigi on Medium]]></description>
        <link>https://medium.com/@dorababuarigi765?source=rss-b36aca4be370------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0RU6g9CcogboJYu_</url>
            <title>Stories by Dorababu Arigi on Medium</title>
            <link>https://medium.com/@dorababuarigi765?source=rss-b36aca4be370------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 23:51:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dorababuarigi765/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why functions are called First-Class Citizens in JavaScript]]></title>
            <link>https://medium.com/@dorababuarigi765/why-functions-are-called-first-class-citizens-in-javascript-c4b4d3e39388?source=rss-b36aca4be370------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4b4d3e39388</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[first-class-citizen]]></category>
            <category><![CDATA[functions-in-javascript]]></category>
            <category><![CDATA[higher-order-function]]></category>
            <category><![CDATA[callback-function]]></category>
            <dc:creator><![CDATA[Dorababu Arigi]]></dc:creator>
            <pubDate>Fri, 17 Jun 2022 12:26:01 GMT</pubDate>
            <atom:updated>2022-06-17T12:26:01.448Z</atom:updated>
            <content:encoded><![CDATA[<p>In any programming language functions are said to be as First- Class citizens if the functions in that language are treated in the say way the variables are treated in that language.</p><p>We know that variables in any language can be</p><ol><li>Assigned to another variable.</li><li>Can be passed as arguments to some functions.</li><li>Can be returned from any function.</li></ol><p>Now, let’s see about the javascript functions:</p><ol><li>Assigning functions to variables:</li></ol><p>var a=function (a,b){</p><p>return a+b;</p><p>}</p><p>console.log(a(2,3));</p><p>// output: 5</p><p>Here you can observe that we have assigned an anonymous function to a, just like assigning a variable to another variable.</p><p>2. Passing functions as arguments to other functions:</p><p>var question=function(){<br> return “What’s the best programming language?”;<br> }<br> var tweet=function(quest){<br> console.log(quest(),”JavaScript is the best programming language”);<br> }<br> tweet(question);</p><p>//output: What’s the best programming language? JavaScript is the best programming language</p><p>Here you can observe that we have passed the function “question” as an argument to the function tweet, just like passing a variable as an argument to any function. Moreover, this way of passing a function to another function is said to be a callback and the function passed will be a callback function(question here).</p><p>3. Returning a function from another function:</p><p>var square=function(a){</p><p>console.log(`The square of the number ${a} is`);</p><p>return function(){</p><p>return a*a;</p><p>}</p><p>}</p><p>var calculation=square(5);</p><p>console.log(calculation());</p><p>//output:</p><p>The square of the number 5 is<br>25</p><p>Here you can observe that square(5) invokes the anonymous function assigned to the square which will then print “The square of the number 5 is” and it will return an anonymous function to the variable calculation. On invoking this calculation to get the output as 25.</p><p>So here we are successful in returning a function from another function and even have successfully invoked that.</p><p>So, all the three points, assigning to variables, passing as arguments to functions, and returning from functions will work for functions in javascript. So, javascript is said to have first-class functions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4b4d3e39388" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Difference between var, let, and const in JavaScript]]></title>
            <link>https://medium.com/@dorababuarigi765/difference-between-var-let-and-const-in-javascript-f2423320e45f?source=rss-b36aca4be370------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2423320e45f</guid>
            <category><![CDATA[var-let-and-const]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[function-scope]]></category>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[block-scope]]></category>
            <dc:creator><![CDATA[Dorababu Arigi]]></dc:creator>
            <pubDate>Fri, 10 Jun 2022 19:10:42 GMT</pubDate>
            <atom:updated>2022-06-10T19:10:42.608Z</atom:updated>
            <content:encoded><![CDATA[<p>In JavaScript, we have three ways to declare a variable. They are:</p><ol><li>var name=”Dorababu”</li><li>let name=”Pranav”</li><li>const name=”Manju”</li></ol><p>The work they do is the same at the top level. They create a variable.</p><p>Now let’s see what makes the difference.</p><h3><strong>var</strong></h3><ol><li>The unique thing about var is that it can be redeclared and also redefined as well.</li></ol><p>Now, what does this mean:</p><p>var a=”Dorababu”</p><p>console.log(a) //Dorababu</p><p>a=”Dora”</p><p>console.log(a) //Dora</p><p>//Here I have redefined the value to of a, which works well.</p><p>var a=”Pranav”</p><p>console.log(a) //Pranav</p><p>//Now, in the same program I have again written var a, but this will still work because of its redeclaration capability.</p><p>2.</p><p>a).var is functional scoped. It means it will only be available inside the function in which it is created. If it doesn’t lie inside any function then it will be global scoped. Let’s see an example:</p><p>var a=”apple”</p><p>console.log(a);</p><p>function fun(){</p><p>console.log(a);</p><p>}</p><p>fun();</p><p>//Output:</p><p>apple</p><p>apple</p><p>The reason that ‘a’ is accessible to the function fun() is that it ‘a’ is not declared inside any function. So, it will have global scope and can be accessed by the fun().</p><p>Let’s see another example:</p><p>function fun(){</p><p>var a=”apple”;</p><p>console.log(a);</p><p>}</p><p>fun();</p><p>console.log(a);</p><p>//output:</p><p>Reference error: a is not defined.</p><p>Here ‘a’ is not available to the outside of the function, since it is declared inside the function, its scope became only functional.</p><p>b).var don’t respect block scope:</p><p>Block scope is nothing but anything written inside { and }.</p><p>var doesn’t follow block scope, let’s see what does this mean through this example:</p><p>{</p><p>var a=”apple”;</p><p>console.log(“apple”);</p><p>}</p><p>console.log(a)</p><p>//Output:</p><p>apple</p><p>apple</p><p>We can observe that even though a is declared inside {} still it is accessible outside the block scope. Because var is not limited by block scope. It is only limited by the functional scope.</p><p>NOTE:</p><p>This is the reason why IIFE (Immediately invoked function expressions) was introduced.</p><p>3. There is no need to initialize the var variable at the time of declaration. It can be done later.</p><p>var a;</p><p>a=”apple”;</p><p>console.log(a);</p><p>//output:</p><p>apple</p><h3>let</h3><ol><li>The let variable can only be declared once in a scope.</li></ol><p>let a=”apple”;</p><p>console.log(a)</p><p>let a=”banana”;</p><p>//output:</p><p>syntax error: variable a has already been declared.</p><p>2. The let variable respects both block scope and functional scope.</p><p>let a=”banana”;</p><p>console.log(a);</p><p>{</p><p>let a=”apple”;</p><p>console.log(a);</p><p>}</p><p>console.log(a);</p><p>//output:</p><p>banana</p><p>apple</p><p>banana</p><p>its scope will only be limited to where it is declared:</p><p>{</p><p>let a=”apple”;</p><p>console.log(a); //apple</p><p>}</p><p>console.log(a);//reference error: a is not defined</p><p>3. The let variable similar to var variable can be initialized later to the variable declaration.</p><h3>const</h3><ol><li>The value stored in the const variable cannot be changed later.</li><li>Initialization and declaration should be done at the same time.</li><li>The above two properties and all other properties of let are obeyed by the const.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2423320e45f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>