<?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: Guru </title>
    <description>The latest articles on DEV Community by Guru  (@rugiguru).</description>
    <link>https://dev.to/rugiguru</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%2F306281%2F4015abd1-48c5-4a6f-b419-9a27f22a3f5f.png</url>
      <title>DEV Community: Guru </title>
      <link>https://dev.to/rugiguru</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rugiguru"/>
    <language>en</language>
    <item>
      <title>Scary Keyword In JavaScript</title>
      <dc:creator>Guru </dc:creator>
      <pubDate>Wed, 07 Apr 2021 15:36:49 +0000</pubDate>
      <link>https://dev.to/rugiguru/scary-keyword-in-javascript-17oj</link>
      <guid>https://dev.to/rugiguru/scary-keyword-in-javascript-17oj</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YwCnctWx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yb8v6fkc555ewrvhu7rb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YwCnctWx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yb8v6fkc555ewrvhu7rb.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yes i call &lt;code&gt;this&lt;/code&gt; key word in JavaScript the most scariest keyword because it kept confusing me for long time even though i was already a JavaScript developer, i encountered this key word when i started my journey as a React developer, let us see how we can make it easier to understand.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Impoorrtant : &lt;code&gt;this&lt;/code&gt; keyword behaves differently when we use it in function  and and object methods.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;let us create a simple file called &lt;code&gt;thisKeyWord.js&lt;/code&gt; and add the following line of code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(this) // {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Inside the regular functions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;let us create a function and do the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function myFunction(){
    console.log(this);
}

myFunction();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in the console we can see that its an &lt;strong&gt;global window object&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ncY3iqvK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/428tkomz7gogkmfdken4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ncY3iqvK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/428tkomz7gogkmfdken4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inside the object methods&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;let us add the following code in the file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let person = {
    name : "Guru",
    age : 29,
    gender : "male",
    getDetails() {
            console.log(this);
    }

};

person.getDetails();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in the console we can see that its the &lt;strong&gt;object&lt;/strong&gt; itself&lt;/p&gt;

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

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

&lt;ol&gt;
&lt;li&gt;Inside the regular functions , &lt;code&gt;this&lt;/code&gt; keyword is an global object&lt;/li&gt;
&lt;li&gt;Inside the object methods its the defined object itself&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I have explained in my youtube video also , please like, share and subscribe to my youtube cahnnel if you like my content&lt;/p&gt;

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

</description>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Make Your Screen Look Like Hacker In Ubuntu</title>
      <dc:creator>Guru </dc:creator>
      <pubDate>Tue, 06 Apr 2021 07:15:06 +0000</pubDate>
      <link>https://dev.to/rugiguru/display-a-screen-like-hacker-in-ubuntu-jpo</link>
      <guid>https://dev.to/rugiguru/display-a-screen-like-hacker-in-ubuntu-jpo</guid>
      <description>&lt;p&gt;while i was searching for fun things we can do in Linux, i found one of the package named &lt;code&gt;cmatrix&lt;/code&gt;, which will display a screen like hacker, so to start with we need to install the package by running following command in ubuntu&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install cmatrix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;after this just run the following command in your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cmatrix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thats it, enjoy the screen.&lt;/p&gt;

&lt;p&gt;if you want to see the demo , please watch my video on &lt;a href="https://www.youtube.com/watch?v=dJEKO6kvhIU"&gt;YouTube&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have made a video on &lt;a href="https://www.youtube.com/watch?v=ARkbgoq239k&amp;amp;t=25s"&gt;Basic linux commands&lt;/a&gt; for beginners also if you are interested&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Run if key changes but not on first render in react</title>
      <dc:creator>Guru </dc:creator>
      <pubDate>Tue, 05 Jan 2021 04:45:33 +0000</pubDate>
      <link>https://dev.to/rugiguru/run-if-key-changes-but-not-on-first-render-in-react-3j72</link>
      <guid>https://dev.to/rugiguru/run-if-key-changes-but-not-on-first-render-in-react-3j72</guid>
      <description>&lt;p&gt;As a developer we might get struck at a place where we do not want to run some specific block of code or some function on the first render of the component in react, and we want to run that function only on some key changes only. As we have &lt;code&gt;useEffect&lt;/code&gt; where we specify our dependencies to watch for changes some thing 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;useEffect(() =&amp;gt; {
    // the call back function or code if the stateVariable changes
}, [stateVariable]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we dont want this above code to run on initial render , we can create a custom hook some thing 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;import React, { useEffect, useRef } from 'react';

const useDidMountEffect = (func, deps) =&amp;gt; {
    const didMount = useRef(false);

    useEffect(() =&amp;gt; {
        if (didMount.current) func();
        else didMount.current = true;
    }, deps);
}

export default useDidMountEffect;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Usage
&lt;/h1&gt;

&lt;p&gt;To use the above component first we have to import it into the component you want to use&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import useDidMountEffect from './path_to_UseDidMountEffect';


useDidMountEffect(() =&amp;gt; {
  // react please run me if 'key' changes, but not on initial render
    myFunction()
}, [stateVariable]);

const myFunction = () =&amp;gt;{
   console.log('i am up and running');
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
