<?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 Saiem Saeed on Medium]]></title>
        <description><![CDATA[Stories by Saiem Saeed on Medium]]></description>
        <link>https://medium.com/@saiemsaeed?source=rss-8bd7cbb00209------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*M52DG3RJvkEwCV69Jl7kkg.jpeg</url>
            <title>Stories by Saiem Saeed on Medium</title>
            <link>https://medium.com/@saiemsaeed?source=rss-8bd7cbb00209------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:52:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saiemsaeed/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[Function Declarations vs Function Expressions — Summed Up]]></title>
            <link>https://medium.com/@saiemsaeed/function-declarations-vs-function-expressions-summed-up-22d4f38e90bc?source=rss-8bd7cbb00209------2</link>
            <guid isPermaLink="false">https://medium.com/p/22d4f38e90bc</guid>
            <category><![CDATA[function-expression]]></category>
            <category><![CDATA[saiem-saeed]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[function-declaration]]></category>
            <dc:creator><![CDATA[Saiem Saeed]]></dc:creator>
            <pubDate>Mon, 22 Jun 2020 16:30:34 GMT</pubDate>
            <atom:updated>2020-06-24T06:34:42.899Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Function Declarations vs Function Expressions — Summed Up</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZlrQJ8B7ObYrAJjUBW8GA.png" /></figure><h4>What is Function Declaration?</h4><p>When a function is defined as a statement that exists as a standalone unit of code and not assigned to a variable, it is called a Function Declaration. It can not be nested in a non-function construct, e.g., Object, Array, etc.</p><p>Just as variable declaration starts with <strong>var</strong> , function declaration starts with keyword <strong>function</strong>.</p><p>According to ECMA Syntax 5 (13.0), a function declaration is defined as</p><pre><strong>function</strong> Identifier (FormalParameterList(opt) ) {FunctionBody}</pre><p>Example of Function Declaration</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cd0d88ade8c13d13cea900b27d8c443/href">https://medium.com/media/7cd0d88ade8c13d13cea900b27d8c443/href</a></iframe><h4>What is Function Expression?</h4><p>Before diving into Function Expression, let’s see what an expression is. In JavaScript, the <strong>expression</strong>is defined as</p><blockquote>An expression is any valid unit of code that resolves to a value. (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Expressions">MDN</a>)</blockquote><p>So, When a function is written as a part of larger expression syntax or assigned to a variable or used a callback or boolean operand, its called a Function Expression. A function defined as a Function Expressions is typically anonymous.</p><p>According to ECMA Syntax 5 (13.0), a function declaration is defined as</p><pre><strong>function</strong> Identifier(opt) (FormalParameterList (opt)) {FunctionBody}</pre><p>Example of Function Expression</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/121e59714a4fbc8adad9d0afdbeb93d9/href">https://medium.com/media/121e59714a4fbc8adad9d0afdbeb93d9/href</a></iframe><p>After a function expression has been stored in a variable, the variable can be used as a function. Functions stored in variables do not need function names. They are always invoked (called) using the variable name.</p><h4>Function Declaration vs Function Expression</h4><p>They’re actually very similar in their definition syntax. How you call them is exactly the same. But the difference lies in how JavaScript runtimes load them into the execution context. The one and the only difference between them is that.</p><blockquote>Function <strong>Declarations</strong> are Hoisted by Interpreter.</blockquote><blockquote>Function <strong>Expressions</strong> are not Hoisted by Interpreter.</blockquote><p>You may be thinking, what is <strong>Hosting</strong> now? 😨</p><blockquote>Javascript interpreter invisibly moves function and variable declarations to the top of the containing scope. And loads them into memory during compile time. This is generally known as Hoisting.</blockquote><p>For more information on Hoisting. Check <a href="http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html">this</a> amazing article</p><p>Let’s see Hoisting in action and how it differs for Function Declarations and Function Expressions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84a6b0d2711a3d4f3ad066caea767432/href">https://medium.com/media/84a6b0d2711a3d4f3ad066caea767432/href</a></iframe><h4>Which one is better?</h4><p>Function Expression. Hold on, there are some reasons for this. There are some cases where you can’t use a function declaration. For example,</p><ul><li>As closures</li><li>As arguments to other functions</li><li>As an Immediately Invoked Function Expressions (IIFE)</li><li>Within, If block.</li></ul><p>So, Its better to always use <strong>function expression </strong>to be consistent throughout your project.</p><h4>Did you know?</h4><p>You can give up to <strong>50 Claps</strong> for an article? Just hold the clap button for a few seconds and bam! Try it out 😋</p><h4><strong>React Out to me on social media</strong></h4><p><a href="https://github.com/saiemsaeed">Github</a>, <a href="https://www.instagram.com/saiemsaeed/">Instagram</a>, and <a href="https://www.linkedin.com/in/saiemsaeed/">LinkedIn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22d4f38e90bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>