<?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: RahulMandyal</title>
    <description>The latest articles on DEV Community by RahulMandyal (@rahulmandyal).</description>
    <link>https://dev.to/rahulmandyal</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%2F844843%2F59511988-e645-4343-a2e8-f049bf79ab52.jpeg</url>
      <title>DEV Community: RahulMandyal</title>
      <link>https://dev.to/rahulmandyal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rahulmandyal"/>
    <language>en</language>
    <item>
      <title>What is hoisting in the javascript.</title>
      <dc:creator>RahulMandyal</dc:creator>
      <pubDate>Thu, 14 Apr 2022 03:10:19 +0000</pubDate>
      <link>https://dev.to/rahulmandyal/what-is-hoisting-in-the-javascript-2fbn</link>
      <guid>https://dev.to/rahulmandyal/what-is-hoisting-in-the-javascript-2fbn</guid>
      <description>&lt;p&gt;Hoisting is very important  and tricky part in the javascript world .When  a program loads  into the   js engine  for execution it will not executed in the same way as we have writeen it. &lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Hoisting *&lt;/em&gt;  means during the declaration phase it will hoist (raise) all the variable declaration and function declaration to the top of the current scope .&lt;br&gt;
Let, s understand it with the help of a example :&lt;/p&gt;

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

&lt;p&gt;In the above example you have seen as we  have writeen our program is not executed in the same way  by the Javascript engine .So now its time to go more deep .Then you all  will be able to understand why this happened.&lt;/p&gt;

&lt;p&gt;When the js  engine execute the code it will creates a global execution context  and  it has two phases .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First Phase(Declaration phase) :&lt;/strong&gt;&lt;br&gt;
In  the first phase (declaration phase ) it will allocate memory  to all the variables and function .&lt;br&gt;
Highest priority is given to the function declaration. Javascript engine will move all the  function declaration  to the top .&lt;br&gt;
Like this :&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;var keyword :&lt;/strong&gt;&lt;br&gt;
During the Execution phase variable declared with var keyword are initialized with undefined value whereas variable declared with let and const keyword are initialized during the execution time only but memory is being allocated to all  the variables during  the declaration phase only.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;let and const keyword&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But if your write the above same code and replace the var keyword  with let and const then it will throw an error Because you can,t  access a variable which is not initialized yet. Because variables declared with let and const are initialized during  the execution phase only.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Function expressions&lt;/strong&gt;&lt;br&gt;
Function expressions are not treated as the same as function declaration .During  the declaration phase they are treated as a variable . &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Execution Phase&lt;/strong&gt;&lt;br&gt;
In the execution phase it will execute code line by line means synchronously . The reason why it will execute all the code line by line is that Javascript engine is single  threaded . &lt;/p&gt;

&lt;p&gt;I hope  now all of you are able to understand what is hoisting in javascript .this article will must help you to understand this topic :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>architecture</category>
    </item>
    <item>
      <title>All you need to know about object destructuring</title>
      <dc:creator>RahulMandyal</dc:creator>
      <pubDate>Sat, 09 Apr 2022 20:04:40 +0000</pubDate>
      <link>https://dev.to/rahulmandyal/javascript-object-destructuring-all-you-need-to-know-about-object-destructuring-5ca3</link>
      <guid>https://dev.to/rahulmandyal/javascript-object-destructuring-all-you-need-to-know-about-object-destructuring-5ca3</guid>
      <description>&lt;p&gt;As we all know javascript es6 version had came with a lot of feature  and it   made javascript slightly better .Object destructring  also came with the es6 version it somehow also made   our job easier .&lt;/p&gt;

&lt;p&gt;Before es6 version when we want to assign object properties into a variable we typically do it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
let user = {
  name : "Rahul thakur",
  age : 19
};
let userName = user.name;
let userAge = user.age;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But now object destructuring  provides us  better syntax that can help us to reduce our code and also provide an alternative way  to assign properties of an object to a variable:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let {name : username , age : userage} =user;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;the  syntax is :&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;{let property1 :variablename , property2 : variablename}= object ;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Make your code more shorter:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your variable have the same name as the properties of the  object then we can make our code more shorter&lt;br&gt;
&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;let {name  , age } = user ;&lt;/code&gt;``&lt;br&gt;
this is equivalent  to the previous one.now instead of writing two two lines of code we can do it within one line of code .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;undefined values :&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Suppose you are trying to assign a property that does not exits in the object then then variable is set to undefined for example : &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZB_1POiq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y4u636sg5a0thfef2m76.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZB_1POiq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y4u636sg5a0thfef2m76.png" alt="Image description" width="880" height="426"&gt;&lt;/a&gt;&lt;br&gt;
Here in this example phone ,lastname,email is not present inside the user object so those variable which are not present inside the obejct are initialized with  the undefiend value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting default values&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;we can assign  a default value to the variable if the property does not exits inside  the  the object then instead of undefined the variable is initialized with  the default value for example :&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--izUNVzKh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26lboekob7193gu64dgv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--izUNVzKh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26lboekob7193gu64dgv.png" alt="Image description" width="880" height="471"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Object destructuring just making our job easier .It provides us better syntax to store object properties  value inside variables with in one line of code  .&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
