<?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: Wesley Smith</title>
    <description>The latest articles on DEV Community by Wesley Smith (@wesjd).</description>
    <link>https://dev.to/wesjd</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%2F20606%2F165c680e-74d1-4fd3-87ea-f1301d6b96fc.jpeg</url>
      <title>DEV Community: Wesley Smith</title>
      <link>https://dev.to/wesjd</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wesjd"/>
    <language>en</language>
    <item>
      <title>Named functions vs Functions as variables in JavaScript</title>
      <dc:creator>Wesley Smith</dc:creator>
      <pubDate>Mon, 29 Jan 2018 04:28:50 +0000</pubDate>
      <link>https://dev.to/wesjd/named-functions-vs-functions-as-variables-in-javascript-3ipl</link>
      <guid>https://dev.to/wesjd/named-functions-vs-functions-as-variables-in-javascript-3ipl</guid>
      <description>&lt;p&gt;Took a quick 10m google to find a debate on this idea, but wasn't able to find anything. &lt;/p&gt;

&lt;p&gt;So really, which is more readable to you:&lt;/p&gt;

&lt;p&gt;This? (named function)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;foo&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bar&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//some code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or this? (function as a variable)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;foo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bar&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//some code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep in mind having other variables in the same scope along with these functions and trying to debug it!&lt;/p&gt;

&lt;p&gt;Personally, where I currently work, we keep a strict concern about the main script functions (ones not inside of a scope) to be what I called &lt;code&gt;named functions&lt;/code&gt;. I've been with the team for ~6 months, and we've had people who originally argue for functions as variables change their stance to that named functions are more readable.&lt;/p&gt;

&lt;p&gt;What's your stance?&lt;/p&gt;

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