<?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: Sumit Kumar Surana</title>
    <description>The latest articles on DEV Community by Sumit Kumar Surana (@ssurana2).</description>
    <link>https://dev.to/ssurana2</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%2F693651%2Fe4c697c3-643d-4144-a14c-1a337207d9ec.jpeg</url>
      <title>DEV Community: Sumit Kumar Surana</title>
      <link>https://dev.to/ssurana2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ssurana2"/>
    <language>en</language>
    <item>
      <title>Semicolon or No semicolon?</title>
      <dc:creator>Sumit Kumar Surana</dc:creator>
      <pubDate>Sun, 23 Jan 2022 17:20:40 +0000</pubDate>
      <link>https://dev.to/ssurana2/semicolon-or-no-semicolon-2d7h</link>
      <guid>https://dev.to/ssurana2/semicolon-or-no-semicolon-2d7h</guid>
      <description>&lt;p&gt;I have 10 years of experience being a JavaScript developer and I forget that semicolon is optional. Adding a semicolon in the end is a simple instinct for me.&lt;/p&gt;

&lt;p&gt;From my point of view, if you are using the right tools like jshint or jslint to catch the syntax errors before pushing the code to your repository, it doesn't matter if you use a semicolon or not. &lt;/p&gt;

&lt;p&gt;I use semicolons in the end because I am tuned that way while working with professionals or mentors who end the statement with a semicolon. I also advocate using semicolons in the end because of the following reasons.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automatic semicolon assertion
&lt;/h3&gt;

&lt;p&gt;I won’t spend too much time explaining about it since it is really well articulated in ecma specs &lt;a href="https://tc39.es/ecma262/#sec-automatic-semicolon-insertion"&gt;https://tc39.es/ecma262/#sec-automatic-semicolon-insertion&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To put it simply, it is better to handle the semicolon ourselves than relying on a compiler/minifier which has a chance of being unpredictable. Especially, when you are using ‘[‘ or ‘(‘ or binary operator or a regex in the next line without ending the previous statement with a semicolon. Refer &lt;a href="https://tc39.es/ecma262/#sec-asi-interesting-cases-in-statement-lists"&gt;https://tc39.es/ecma262/#sec-asi-interesting-cases-in-statement-lists&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I prefer lesser risk on my production code and I believe in the statement that if something can go wrong it will definitely go wrong.&lt;/p&gt;

&lt;h3&gt;
  
  
  Consistency
&lt;/h3&gt;

&lt;p&gt;Most developers nowadays are full stack developers who have dabbled in one or more backend languages. And most of the popular backend languages (apart from &lt;a href="https://www.python.org"&gt;python&lt;/a&gt; that I know of) have statements ending with semicolon. &lt;/p&gt;

&lt;p&gt;So when a developer tends to switch between other programming languages and JavaScript they don't have to unlearn the idea of not putting the semicolon in the end. Remember it is optional. So no offense if someone puts it or omits it. But the idea is to keep a single standard and consistency so that it doesn't cause any confusion among team members on what to follow. So make sure you choose one or else brace yourself for resolving lots of ideology clashes among the team members like the discussion going on at &lt;a href="https://davidwalsh.name/javascript-semicolons"&gt;https://davidwalsh.name/javascript-semicolons&lt;/a&gt;.&lt;/p&gt;

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