<?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>Forem: Blue Turtle</title>
    <description>The latest articles on Forem by Blue Turtle (@blueturtle).</description>
    <link>https://forem.com/blueturtle</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%2Forganization%2Fprofile_image%2F601%2F57a7a54e-43f5-4a2d-a4bf-119285db0ead.png</url>
      <title>Forem: Blue Turtle</title>
      <link>https://forem.com/blueturtle</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/blueturtle"/>
    <language>en</language>
    <item>
      <title>With Firefox69 Privacy Is the Default</title>
      <dc:creator>Islam Sayed</dc:creator>
      <pubDate>Sun, 08 Sep 2019 10:23:41 +0000</pubDate>
      <link>https://forem.com/blueturtle/with-firefox69-privacy-is-the-default-4iga</link>
      <guid>https://forem.com/blueturtle/with-firefox69-privacy-is-the-default-4iga</guid>
      <description>&lt;p&gt;&lt;strong&gt;Privacy&lt;/strong&gt; is not an option in &lt;a href="https://www.mozilla.org/en-US/firefox/new/" rel="noopener noreferrer"&gt;Firefox69&lt;/a&gt; browser version. It is &lt;em&gt;default by default&lt;/em&gt;. With the new release of the browser, these are the new features it prsents for its users:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
Block Third-Party Tracking Cookies (by default).&lt;/li&gt;
&lt;li&gt;
Block Cryptominers (by default).&lt;/li&gt;
&lt;li&gt;
Block Fingerprinting (on strict mode - you have to enable it,and I'm going to show you how).&lt;/li&gt;
&lt;li&gt;
Block autoplay video's audio (by default).&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Block Third-Party Tracking Cookies
&lt;/h3&gt;

&lt;p&gt;As mentioned in &lt;a href="https://blog.mozilla.org/blog/2019/09/03/todays-firefox-blocks-third-party-tracking-cookies-and-cryptomining-by-default/" rel="noopener noreferrer"&gt;mozilla blog post&lt;/a&gt;, the new feature works behind-the-scenes to keep a company from forming a profile of you based on their tracking of your browsing behavior across websites — often without your knowledge or consent. Those profiles and the information they contain may then be sold and used for purposes you never knew or intended.&lt;/p&gt;

&lt;p&gt;Here is how to see the blocked list for a website:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fw4ceomvhcwpkby9glnhf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fw4ceomvhcwpkby9glnhf.png" alt="Click on info icon beside address bar."&gt;&lt;/a&gt;&lt;/p&gt;
Click on info icon beside address bar.



&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkuuixsjtwrpd7st5kysz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkuuixsjtwrpd7st5kysz.png" alt="Click on Cookies."&gt;&lt;/a&gt;&lt;/p&gt;
Click on Cookies.






&lt;h3&gt;
  
  
  Block Cryptominers
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.techopedia.com/definition/33729/cryptomining" rel="noopener noreferrer"&gt;Cryptominers&lt;/a&gt; access your CPU without your knowledge, make excessive computational operations and this leads to slowing down your machine, and drain your batteries. Allof these for creating cryptocurrency not for you but for them. Firefox blocks them by default. &lt;/p&gt;




&lt;h3&gt;
  
  
  Block Fingerprinting
&lt;/h3&gt;

&lt;p&gt;Fingerprinting scripts have the ability to take a snapshot of your machine's configuration when you visit a website. This snapshot can then be used to track you accross the web. Firefox blocks fingerprinting by enabling &lt;em&gt;strict mode&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To turn on strict mode, you will have to go to &lt;strong&gt;options&lt;/strong&gt;, then chose &lt;strong&gt;Privacy &amp;amp; Security&lt;/strong&gt;, and check &lt;strong&gt;Strict&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fydc0r2tvjivq8lcvhz1f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fydc0r2tvjivq8lcvhz1f.png" alt="How to enable strict mode"&gt;&lt;/a&gt;&lt;/p&gt;
How to enable strict mode






&lt;h3&gt;
  
  
  Block autoplay video's audio
&lt;/h3&gt;

&lt;p&gt;You have three options with videos in Firefox:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Allow audio and video autoplay.&lt;/li&gt;
&lt;li&gt;Block audio only(default).&lt;/li&gt;
&lt;li&gt;Block audio and video until you press the play button.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can alter the setting easily by going to &lt;strong&gt;Privacy &amp;amp; Security&lt;/strong&gt;, then at &lt;strong&gt;Permissions&lt;/strong&gt; locate the &lt;strong&gt;Autoplay&lt;/strong&gt; settings.&lt;/p&gt;




&lt;p&gt;As you see the new Firefox treats user &lt;em&gt;privacy&lt;/em&gt; as a first priority and this is really a win to this browser, and its users.&lt;/p&gt;

</description>
      <category>privacy</category>
      <category>browser</category>
      <category>news</category>
    </item>
    <item>
      <title>Now Use Material-UI Icons With Super Ease</title>
      <dc:creator>Islam Sayed</dc:creator>
      <pubDate>Wed, 28 Aug 2019 12:27:56 +0000</pubDate>
      <link>https://forem.com/blueturtle/now-use-material-ui-icons-with-super-ease-3f54</link>
      <guid>https://forem.com/blueturtle/now-use-material-ui-icons-with-super-ease-3f54</guid>
      <description>&lt;p&gt;Instead of searching for icons in &lt;a href="https://material.io/tools/icons/?style=baseline" rel="noopener noreferrer"&gt;Material icons&lt;/a&gt;, and then trying to figure out what the required icon component name would look like, now you can directly search for any icon among 1,000+ official Material icons converted to svg icon components.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1164302839033794561-357" src="https://platform.twitter.com/embed/Tweet.html?id=1164302839033794561"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1164302839033794561-357');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1164302839033794561&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;The search feature is super easy. After you select an icon a pop up opens with the import of such icon.&lt;/p&gt;

&lt;p&gt;You can also choose between icon styles (Filled, Outlined, Rounded, Two tone, and Sharp) in the left side bar.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/xN46x0piLZE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;As announced in Material-UI &lt;a href="https://twitter.com/MaterialUI/status/1164303661880754177" rel="noopener noreferrer"&gt;tweet&lt;/a&gt; that their synonyms list is not perfect yet. And they will refine it based on the search usage.&lt;/p&gt;

</description>
      <category>react</category>
      <category>news</category>
    </item>
    <item>
      <title>Modular Front-end development</title>
      <dc:creator>Islam Sayed</dc:creator>
      <pubDate>Mon, 01 Apr 2019 06:54:01 +0000</pubDate>
      <link>https://forem.com/blueturtle/modular-front-end-development-23ej</link>
      <guid>https://forem.com/blueturtle/modular-front-end-development-23ej</guid>
      <description>&lt;p&gt;🎙 I am making a research for an article about modular approach in Front-end development 💻. I'd be thankful if anyone could help me with good resources. 💚&lt;/p&gt;

</description>
      <category>help</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why Do We Write &lt;! DOCTYPE html&gt; ?</title>
      <dc:creator>Islam Sayed</dc:creator>
      <pubDate>Mon, 11 Mar 2019 22:12:47 +0000</pubDate>
      <link>https://forem.com/blueturtle/why-do-we-write--doctype-html--508i</link>
      <guid>https://forem.com/blueturtle/why-do-we-write--doctype-html--508i</guid>
      <description>&lt;p&gt;Yes, this is for the absolute beginner, and also for those non-beginners who forgot. I am going to  look back behinds and re-discover things we take as granted by asking "WHAT", "WHY", and "HOW".&lt;/p&gt;




&lt;h4&gt;
  
  
  Why do we write &amp;lt;! DOCTYPE html&amp;gt; ?
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;code&gt;&amp;lt;! DOCTYPE html&amp;gt;&lt;/code&gt; is the first html tag written at the beginning of any html file. It is not an element and doesn't has content or closing tag.&lt;br&gt;
Its job is to tell the browser that the document being rendered is an HTML document. That's the reason for its position to be the first thing the browser read.&lt;/p&gt;




&lt;h4&gt;
  
  
  But what would happen if we didn't write it?
&lt;/h4&gt;

&lt;p&gt;If browser didn't find a &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Doctype"&gt;DOCTYPE&lt;/a&gt; declaration, it would enter &lt;a href="https://en.m.wikipedia.org/wiki/Quirks_mode"&gt;quirks mode&lt;/a&gt;🤔 which is a technique used by browsers to try to support old web pages that has been made for Navigator 4 and Internet Explorer 5. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode"&gt;Read about it here&lt;/a&gt;. &lt;br&gt;
This means that your website will have different behavior and look with different browsers especially if it has new HTML elements and features.&lt;/p&gt;

</description>
      <category>html</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>1. let, const and ... var</title>
      <dc:creator>Islam Sayed</dc:creator>
      <pubDate>Mon, 11 Feb 2019 13:58:45 +0000</pubDate>
      <link>https://forem.com/blueturtle/1-const-let-and--var-4cdh</link>
      <guid>https://forem.com/blueturtle/1-const-let-and--var-4cdh</guid>
      <description>&lt;p&gt;ES6 has introduced some new syntax features. One of them was key words &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const"&gt;const&lt;/a&gt;, and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let"&gt;let&lt;/a&gt; to declare variables. Let's talk about why they are preferred over &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var"&gt;var&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Scope&lt;/strong&gt;🔭
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;var&lt;/code&gt; has a function &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Scope"&gt;scope&lt;/a&gt;. This means it is accessible anywhere in the function it is defined inside. See this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;buyHerChocolate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onDiet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onDiet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;decision&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Don't do it!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;decision&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Go buy it!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;decision&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;buyHerChocolate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="c1"&gt;//"Don't do it!"&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;decision&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="c1"&gt;//Uncaught ReferenceError: decision is not defined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As you see &lt;em&gt;decision&lt;/em&gt; variable defined with &lt;code&gt;var&lt;/code&gt; was availabe inside the function scope, but when we tried to log it outside the function the console throws an error &lt;code&gt;decision is not defined&lt;/code&gt; as if it's never existed.&lt;/p&gt;

&lt;p&gt;On the contrary, &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; have block &lt;code&gt;{}&lt;/code&gt; scope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;buyHerChocolate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onDiet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onDiet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;decision&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Don't do it!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;decision&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;decision&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Go buy it!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;decision&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;decision&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;buyHerChocolate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;//"Don't do it!"&lt;/span&gt;
&lt;span class="c1"&gt;//Uncaught ReferenceError: decision is not defined&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;decision&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="c1"&gt;//Uncaught ReferenceError: decision is not defined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Surprise! Logging the value of decision inside the expression block resulted in the predicted string while doing the same out of the block throw error and out of the function scope also throws an error.&lt;/p&gt;

&lt;p&gt;The same happens with &lt;code&gt;const&lt;/code&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Hoisting&lt;/strong&gt;⏫
&lt;/h3&gt;

&lt;p&gt;Variables declared with &lt;code&gt;var&lt;/code&gt; are &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Hoisting"&gt;hoisted&lt;/a&gt; to the top of their scope. It is important to notice that the variable declaration is what is being hosted not the assignment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="c1"&gt;//undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;What happened?! The &lt;code&gt;console.log()&lt;/code&gt; function will not get executed until hoisting any &lt;code&gt;var&lt;/code&gt; variable. Therefore, &lt;code&gt;var x&lt;/code&gt;; will go up to the top of the global scope. Then console.log(x) is executed and logs undefined, because x has no value at that time. The x is assigned the value 5. It will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Because of that if we &lt;code&gt;console.log(x)&lt;/code&gt; after that it would log 5 to the console.&lt;br&gt;
This quirky behavior can introduce bugs in larger programs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are not hoisted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="c1"&gt;//Uncaught ReferenceError: x is not defined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Declaration &amp;amp; Assignment&lt;/strong&gt;✒️
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;var&lt;/code&gt; variables can be re-declared and reassigned different value multiple times in the same scope. &lt;br&gt;
&lt;code&gt;let&lt;/code&gt; variables can not be re-declared but can be reassigned in the same scope.&lt;br&gt;
&lt;code&gt;const&lt;/code&gt; variables can not be re-declared or reassigned in the same scope. In addition to that they must be declared and assigned a value at the same time. So we can not do that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="c1"&gt;//Uncaught SyntaxError: Missing initializer in const declaration&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;But we must do that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="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;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So if your variable would have changed values, declare it using &lt;code&gt;let&lt;/code&gt;, if not always use &lt;code&gt;const&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;These differences between them and &lt;code&gt;var&lt;/code&gt; will prevent naming conflictions.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Conclusion:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;For the mentioned reasons you should use &lt;code&gt;const&lt;/code&gt; in all cases except when the variable would be reassigned new values. At such cases use &lt;code&gt;let&lt;/code&gt; instead. Most of articles recommend developers to avoid using &lt;code&gt;var&lt;/code&gt;. Why would anyone use &lt;code&gt;var&lt;/code&gt; anymore?!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Do you agree with me about that? Please, leave a comment telling me your opinion.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;For further readings:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;📌&lt;a href="https://medium.com/@josephcardillo/the-difference-between-function-and-block-scope-in-javascript-4296b2322abe"&gt;The Difference Between Function and Block Scope in JavaScript&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌&lt;a href="https://www.sitepoint.com/demystifying-javascript-variable-scope-hoisting/"&gt;Demystifying JavaScript Variable Scope Hoisting&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌&lt;a href="https://medium.com/javascript-in-plain-english/https-medium-com-javascript-in-plain-english-what-is-hoisting-in-javascript-a63c1b2267a1"&gt;What is Hoisting in JavaScript?&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>es6</category>
      <category>beginners</category>
      <category>variables</category>
    </item>
  </channel>
</rss>
