<?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: DFeliciano3</title>
    <description>The latest articles on DEV Community by DFeliciano3 (@dfeliciano3).</description>
    <link>https://dev.to/dfeliciano3</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%2F863843%2F5d7625ba-734b-4bcd-ab18-9c712db447a2.png</url>
      <title>DEV Community: DFeliciano3</title>
      <link>https://dev.to/dfeliciano3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dfeliciano3"/>
    <language>en</language>
    <item>
      <title>Scopes in Javascript</title>
      <dc:creator>DFeliciano3</dc:creator>
      <pubDate>Mon, 27 Jun 2022 02:33:27 +0000</pubDate>
      <link>https://dev.to/dfeliciano3/scopes-in-javascript-4525</link>
      <guid>https://dev.to/dfeliciano3/scopes-in-javascript-4525</guid>
      <description>&lt;p&gt;Have you ever wondered how you can possibly be getting a Reference Error stating your variable is undefined if you know you have already declared your variable? &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gaVYpOMr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpuc82s0irkyp214pswm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gaVYpOMr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpuc82s0irkyp214pswm.png" alt="confused" width="194" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hmm... let's take a look at the code again... Yep it's there! So how is that possible?! &lt;strong&gt;The Scope Chain&lt;/strong&gt; that's how! Location, location, location matters, or in other words, the environment of where your variable has been declared. &lt;/p&gt;

&lt;p&gt;In Javascript, the term scope refers to the location of the variable and how a variable is accessible. Depending on where the variable is stored, it is only accessible in its environment and no one outside that environment can access that variable. &lt;/p&gt;

&lt;p&gt;As I have learned in Phase 1, there are 3 types of scopes in Javascript: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- Global Scope&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- Local Scope&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- Block Scope&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AJJMsxgv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32u555ydlqw0rwgr7q5x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AJJMsxgv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32u555ydlqw0rwgr7q5x.png" alt="https://www.stevethedev.com/blog/programming/javascript-scope-primer" width="225" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let us go into detail to better understand these scopes...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global Scope&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Variables that are declared with var, const, or let can be accessible when declared outside of a function or a block. We can access these variables outside of any function, which means it's been declared globally. &lt;/p&gt;

&lt;p&gt;For example: &lt;/p&gt;

&lt;p&gt;const setGlobalVar = "I am declared in the global scope." &lt;/p&gt;

&lt;p&gt;function sayHello(){ &lt;br&gt;
      console.log(setGlobalVar)&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;setGlobalVar&lt;br&gt;
sayHello()&lt;/p&gt;

&lt;p&gt;What do you think the above output would be? Let's take a quick look...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t4Hb5Gts--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdzh1bnias6643j7wd6v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t4Hb5Gts--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdzh1bnias6643j7wd6v.png" alt="Example of Global Scoping" width="331" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you'll notice that I declared the variable outside of the function as well as called it within the function, yet I was still able to access the variable in both places! &lt;/p&gt;

&lt;p&gt;Now, let us talk about the &lt;strong&gt;Local Scope&lt;/strong&gt;...&lt;/p&gt;

&lt;p&gt;Variables that are created within a function are considered locally scoped. In other words, that variable can only be accessed within that function. &lt;/p&gt;

&lt;p&gt;For example: &lt;/p&gt;

&lt;p&gt;const num = 9 &lt;/p&gt;

&lt;p&gt;function print() {&lt;br&gt;
    const createLocalScope = "I am declared within a function."&lt;br&gt;
    console.log(createLocalScope)&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;print()&lt;/p&gt;

&lt;p&gt;if (num &amp;lt; 12) {&lt;br&gt;
  console.log(createLocalScope)&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Can you guess the output?&lt;/p&gt;

&lt;p&gt;Let's take a look... &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UgTmpUs1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvq5omtym9bmlplc1s9d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UgTmpUs1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvq5omtym9bmlplc1s9d.png" alt="Example of Local Scoping" width="322" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, when we call the function we can access the variable (createLocalScope) from within the print function. But when we try to access the variable again in the following if statement, we get a Reference Error stating that the variable is not defined. This is because the if statement is outside of the function, therefore has no access to that variable.&lt;/p&gt;

&lt;p&gt;Finally, let us discuss &lt;strong&gt;Block Scope&lt;/strong&gt;... &lt;/p&gt;

&lt;p&gt;Variables in block scope are usually created with &lt;strong&gt;curly braces&lt;/strong&gt; (&lt;strong&gt;{}&lt;/strong&gt;) where it's used within logic statements,  such as&lt;br&gt;
: &lt;strong&gt;if statements, else statements&lt;/strong&gt;, and &lt;strong&gt;switch statements&lt;/strong&gt;. It's also used in loops, such as &lt;strong&gt;while, do while&lt;/strong&gt;, and &lt;strong&gt;for loops&lt;/strong&gt;. This means variables are only accessible within the code block. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;:In ES6, only const and let keywords can declare in the block scope. &lt;/p&gt;

&lt;p&gt;Check it out my final examples: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uDm5G-jZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3579lcxj5musi1fm873s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uDm5G-jZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3579lcxj5musi1fm873s.png" alt="block scope 1" width="320" height="262"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tO1q56eD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxulxrv2rjfskbppc8vl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tO1q56eD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxulxrv2rjfskbppc8vl.png" alt="confusion" width="301" height="168"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As I have mentioned previously, looking at this code you would say why the ReferenceError? the variable (i) was defined with the let keyword. But take a look at &lt;strong&gt;where&lt;/strong&gt; I am invoking the variable... &lt;strong&gt;outside of the block ({})&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Now, let's try invoking it &lt;strong&gt;within&lt;/strong&gt; the block scope and see what returns... &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--h0mSVg46--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dytp44hcpw9uqlz3jyc9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--h0mSVg46--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dytp44hcpw9uqlz3jyc9.png" alt="block scope" width="324" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8EPiWhrn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/52z5jz8hitfpt6uo6klh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8EPiWhrn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/52z5jz8hitfpt6uo6klh.png" alt="it makes sense now" width="223" height="226"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Scoping refers to the location of the variable and how a variable is accessible.&lt;/p&gt;

&lt;p&gt;Global variables can be accessed anywhere, locally scoped variables are only accessed within a function, and blocked scope variables using the keywords: let or const, are accessed within the block code in curly braces ({}). &lt;/p&gt;

&lt;p&gt;Although the concept of scopes in JavaScript may confuse many new developers (such as myself), understanding the fundamentals is essential because &lt;br&gt;
it will help you, as a developer, become more efficient at writing and executing code! &lt;/p&gt;

&lt;p&gt;Thank you for taking the time to read! Hope my examples were able to help understand and visualize how scoping works! &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>Find Your Balance to Help Prevent Burnout...</title>
      <dc:creator>DFeliciano3</dc:creator>
      <pubDate>Sun, 26 Jun 2022 20:05:22 +0000</pubDate>
      <link>https://dev.to/dfeliciano3/find-your-balance-to-help-prevent-burnout-4ebm</link>
      <guid>https://dev.to/dfeliciano3/find-your-balance-to-help-prevent-burnout-4ebm</guid>
      <description>&lt;p&gt;Do you ever feel like you've reached your limit being unable to balance it all? Whether it's balancing your personal life, work, school, or parenting? &lt;/p&gt;

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

&lt;p&gt;I've experienced moments where suddenly I felt exhausted, unmotivated, irritated, and couldn't focus.   &lt;/p&gt;

&lt;p&gt;Sometimes I was sure I was fine and maybe needed more sleep, but how can I sleep when I had to complete a lab? How can I complete the lab if I wasn't comprehending or processing the information I was attempting to understand? How can I do all this and find the time to work, parent, and maintain my home? So naturally, I began to doubt myself in everything.&lt;/p&gt;

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

&lt;p&gt;I felt like I needed to get it all done regardless of how I felt at that moment, but it continued to weigh on me. The more I pushed myself too hard the heavier the doubt sank in. &lt;/p&gt;

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

&lt;p&gt;Someone mentioned to me that I might be experiencing burnout. So I decided to do some research online. After reading numerous articles, everything I read in regards to the symptoms all sounded too familiar, and suddenly all made sense. I was indeed experiencing burnout. Therefore, it was time to get it together, recover, and keep moving forward! &lt;/p&gt;

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

&lt;p&gt;The best way to begin was to create a plan for time management! We all do it. We take on too many tasks all at once, forget to find time for ourselves, or even believe that we can't enjoy a personal life or self-care just because we have to work, study, and take care of family. &lt;/p&gt;

&lt;p&gt;It shouldn't be all work and no play! Find the time to balance it all and appreciate the process! &lt;/p&gt;

&lt;p&gt;It was essential to be able to be my best self while accomplishing it all, and finding my confidence again! &lt;/p&gt;

&lt;p&gt;My time management involved studying during downtime while I was at work so that when I got home I used the time to enjoy my time with my family. On weekends I would start the day by doing something I enjoyed. Once that was done I'd tell my partner to take the kids for 2 hours to do an activity while I studied a bit more or completed a lab. &lt;/p&gt;

&lt;p&gt;While my time management wasn't perfect every day, it was improving! In addition, I was surrounded by support and realized I never used my voice to ask for help. Once I voiced it, it became even easier. &lt;/p&gt;

&lt;p&gt;My advice to anyone who might feel the same feelings that I've mentioned at the beginning of this blog would be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pace yourself. Don't compare yourself to the next person. We all have different situations that allow us to complete a task at a different pace. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find someone you can relate to that can help uplift you when you begin to doubt yourself and you can do the same for them. Remind yourself that you can do anything you put your mind to. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Manage your time as best you can by planning your day or week. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do something you enjoy. Whether it's reading a book, going for a walk, spending the day out with your kids, or self-care.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Take a break when you need it. Set a timer if you can. So if you've spent 30 minutes trying to complete a lab, test, or code... TAKE A BREAK! Walk away from the computer and come back to it later. Or better yet, ASK FOR HELP! &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't let burnout control your emotions, your confidence, or your performance. Take control and accomplish your goals by finding a balance ❤️. &lt;/p&gt;

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

</description>
      <category>beginners</category>
      <category>productivity</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
