<?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: AshaS22</title>
    <description>The latest articles on DEV Community by AshaS22 (@ashas22).</description>
    <link>https://dev.to/ashas22</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F260672%2Fcbba3574-c94b-455c-a9aa-19d8769d2ea3.jpg</url>
      <title>DEV Community: AshaS22</title>
      <link>https://dev.to/ashas22</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ashas22"/>
    <language>en</language>
    <item>
      <title>Day 4: Hoisting in JS</title>
      <dc:creator>AshaS22</dc:creator>
      <pubDate>Sat, 10 Oct 2020 17:34:57 +0000</pubDate>
      <link>https://dev.to/ashas22/day-4-hoisting-in-js-3l8h</link>
      <guid>https://dev.to/ashas22/day-4-hoisting-in-js-3l8h</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N3ij-JHo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qr5zqovwv8oisdrg5qjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N3ij-JHo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qr5zqovwv8oisdrg5qjm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Hoisting is the mechanism where the JS interpreter scan the code and hoists the variables and functions at the top so that they can be accessed before declaring them.&lt;/p&gt;

&lt;p&gt;Javascript handles hoisting of variables and functions differently. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variable Hoisting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;var&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(name) // undefined&lt;br&gt;
var name = "xyz"&lt;br&gt;
console.log(name) // "xyz"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After hoisting, the above code looks like the code snippet written below&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var name;&lt;br&gt;
console.log(name) // undefined&lt;br&gt;
name = "xyz"&lt;br&gt;
console.log(name) //&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Hence the first line of &lt;code&gt;console.log(name)&lt;/code&gt; outputs undefined instead of throwing an error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;let and const&lt;/strong&gt;&lt;br&gt;
They way hoisting is handled with let and const is different than how var is handled. We wont be able to access the variable until it is declared.&lt;/p&gt;

&lt;p&gt;Lets look at the previous example with let keyword&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(name) // throws error&lt;br&gt;
let name = "xyz"&lt;br&gt;
console.log(name) // "xyz"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This happens because, in case of var, before executing the code line by line, variables are declared and initialised with &lt;em&gt;undefined&lt;/em&gt;. But, let/const doesn't get initialised until it finds the initialisation in the code. So, when we try to access the variable, it throws an error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function Hoisting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In JS there are three ways of in which we create function.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Function Declaration&lt;/li&gt;
&lt;li&gt;Function Expression&lt;/li&gt;
&lt;li&gt;Arrow functions&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Function Declaration&lt;/strong&gt;&lt;br&gt;
Ex of regular function declaration&lt;/p&gt;

&lt;p&gt;&lt;code&gt;function addNum(a, b){&lt;br&gt;
    return a+b;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When the interpreter scans the JS code, regular function definitions are hoisted at the top and made available at all other places&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(addNum(4, 5)) //prints 9&lt;br&gt;
function addNum(a, b){&lt;br&gt;
    return a+b;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once this code is hoisted it looks as below &lt;/p&gt;

&lt;p&gt;&lt;code&gt;//Hoisted function definition&lt;br&gt;
console.log(addNum(4, 5)) //prints 9&lt;br&gt;
    ...&lt;br&gt;
    ...&lt;br&gt;
   Rest of the code follows&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function Expression&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(add(4, 5)) //throws error add is not a function&lt;br&gt;
var add = function (a, b){&lt;br&gt;
    return a+b;&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
functions Expressions are not completely hoisted in JS, Instead only declarations are hoisted bcz, it is only recognised as variable.&lt;/p&gt;

&lt;p&gt;In the same way, when a function is referenced using &lt;em&gt;let&lt;/em&gt; keyword, hoisting behaves the same way as that of regular let.&lt;br&gt;
Ex: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(add(4, 5)) //throws error&lt;br&gt;
let add = function (a, b){&lt;br&gt;
    return a+b;&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Arrow functions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Just like function Expressions, arrow functions are not hoisted in JS&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Day 3 : Continuation of Weather App Implementation</title>
      <dc:creator>AshaS22</dc:creator>
      <pubDate>Wed, 07 Oct 2020 17:35:48 +0000</pubDate>
      <link>https://dev.to/ashas22/day-3-continuation-of-weather-app-implementation-4i0p</link>
      <guid>https://dev.to/ashas22/day-3-continuation-of-weather-app-implementation-4i0p</guid>
      <description>&lt;p&gt;Application Components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Input box to take user input&lt;/li&gt;
&lt;li&gt;Search Button&lt;/li&gt;
&lt;li&gt;Card to display the temperature information&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Currently i am using hardcoded data. As a further step, i am planning to fetch data from a weather Api and make use of that in the application rendering.&lt;/p&gt;

&lt;p&gt;Initial screen &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zo9DYhMo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iiwrqzv3aow9ouqgqi2m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zo9DYhMo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/iiwrqzv3aow9ouqgqi2m.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After Search Result&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mP_962Lh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mxdlt02mr32hg9nfptd1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mP_962Lh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mxdlt02mr32hg9nfptd1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Things to-do next:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fetch data from an API&lt;/li&gt;
&lt;li&gt;Make UI look better&lt;/li&gt;
&lt;li&gt;Handle all corner cases&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>100daysofcode</category>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Day2: Working on Weather Application</title>
      <dc:creator>AshaS22</dc:creator>
      <pubDate>Tue, 06 Oct 2020 17:19:59 +0000</pubDate>
      <link>https://dev.to/ashas22/day2-working-on-weather-application-1379</link>
      <guid>https://dev.to/ashas22/day2-working-on-weather-application-1379</guid>
      <description>&lt;p&gt;Today I worked on a sample weather application. &lt;/p&gt;

&lt;p&gt;Weather application consists on sample Data in the form of JSON. In the UI when the user enters the name of a city, application has to perform search n the sample data that is stored and the match weather information has to render in the form of a card.&lt;/p&gt;

&lt;p&gt;I only have basic structure of the Project. Will be uploading the implementation details once the project is on github.&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Day1: Basic React application to understand React State</title>
      <dc:creator>AshaS22</dc:creator>
      <pubDate>Mon, 05 Oct 2020 17:01:27 +0000</pubDate>
      <link>https://dev.to/ashas22/day1-basic-react-application-to-understand-react-state-22ce</link>
      <guid>https://dev.to/ashas22/day1-basic-react-application-to-understand-react-state-22ce</guid>
      <description>&lt;p&gt;In this 100daysofcode i am hoping to get a better understanding of ReactJS, Javascript, CSS, HTML and Redux.&lt;/p&gt;

&lt;p&gt;Today i have worked on a simple react application to understand the behaviour of React States.&lt;/p&gt;

&lt;p&gt;State in React application represents any component state at a particular instance. Any modification/action in the UI might affect it. We prefer to keep the Dynamic data as State in React Application.&lt;/p&gt;

&lt;p&gt;Link for Sample Practice Code: &lt;a href="https://codesandbox.io/s/busy-butterfly-ylmk9?file=/src/App.js"&gt;https://codesandbox.io/s/busy-butterfly-ylmk9?file=/src/App.js&lt;/a&gt;&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>react</category>
      <category>applicationdevelopment</category>
      <category>day1</category>
    </item>
  </channel>
</rss>
