<?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: Ricardo Garrido</title>
    <description>The latest articles on DEV Community by Ricardo Garrido (@rych182).</description>
    <link>https://dev.to/rych182</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%2F310083%2Fb469afb4-9dda-4272-a3a9-98a915d30e78.jpeg</url>
      <title>DEV Community: Ricardo Garrido</title>
      <link>https://dev.to/rych182</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rych182"/>
    <language>en</language>
    <item>
      <title>Var VS Let in Javascript</title>
      <dc:creator>Ricardo Garrido</dc:creator>
      <pubDate>Mon, 25 Oct 2021 22:24:11 +0000</pubDate>
      <link>https://dev.to/rych182/var-vs-let-in-javascript-2l47</link>
      <guid>https://dev.to/rych182/var-vs-let-in-javascript-2l47</guid>
      <description>&lt;p&gt;In Javascript, you can declare a variable using “Var” or “let” BUT there is an inconvenient, don’t worry, I will give you context.&lt;br&gt;
Some years ago(2015) Javascript changed. Var had a global scope before 2015, BUT with ecmascript6 it changed because We can use “Let” to declare a variable.&lt;br&gt;
You shouldn’t use “Var” because it is considered a bad practice , It can get you into a value reassignment problem.&lt;br&gt;
Example:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4y821r1b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wf7afdp7cpz1wpdwme10.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4y821r1b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wf7afdp7cpz1wpdwme10.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example I created a variable using “var” and printed on console three times to show you this…&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8B-7jy7S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxj61wwgusiyeny0vu29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8B-7jy7S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxj61wwgusiyeny0vu29.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that the variable var was added to window’s global object.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sFokI7Na--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3587w57hygfk756fz27.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sFokI7Na--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3587w57hygfk756fz27.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--22G47b1C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mitp6n2gk1i4terd42it.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--22G47b1C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mitp6n2gk1i4terd42it.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;BUT if you create a variable using LET, you won’t have that problem, and the variable LET could be a local or global variable.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3n9JMkW0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3g4x12a77nsqmx4w2w9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3n9JMkW0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3g4x12a77nsqmx4w2w9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope I have helped you by solving this question and You have saved time.&lt;br&gt;
I look forward to your comments, have a nice day. =D&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
