<?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: Indrakant Mishra</title>
    <description>The latest articles on DEV Community by Indrakant Mishra (@indrakantm23).</description>
    <link>https://dev.to/indrakantm23</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%2F607114%2F31e24bed-8b90-496f-9b15-4f9d49ef79d8.jpeg</url>
      <title>DEV Community: Indrakant Mishra</title>
      <link>https://dev.to/indrakantm23</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/indrakantm23"/>
    <language>en</language>
    <item>
      <title>Deep clone objects in javascript</title>
      <dc:creator>Indrakant Mishra</dc:creator>
      <pubDate>Sun, 05 May 2024 17:38:55 +0000</pubDate>
      <link>https://dev.to/indrakantm23/deep-clone-objects-in-javascript-35af</link>
      <guid>https://dev.to/indrakantm23/deep-clone-objects-in-javascript-35af</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5n9lqjefqzsyfdwvla5j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5n9lqjefqzsyfdwvla5j.png" alt="Image description" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>object</category>
      <category>deepclone</category>
      <category>structuredclone</category>
    </item>
    <item>
      <title>Open github repo in Visual studio code without cloning or downloading on local</title>
      <dc:creator>Indrakant Mishra</dc:creator>
      <pubDate>Tue, 10 Oct 2023 02:23:58 +0000</pubDate>
      <link>https://dev.to/indrakantm23/open-github-repo-in-visual-studio-code-without-cloning-or-downloading-on-local-47gp</link>
      <guid>https://dev.to/indrakantm23/open-github-repo-in-visual-studio-code-without-cloning-or-downloading-on-local-47gp</guid>
      <description>&lt;p&gt;Hey guys, many times we need to just download or clone the repo which we are not even going to keep in local for long time and delete it after checking the code in our IDE. So to remove all these and just review the github repo code online itself in popular VSCode editor we have a trick which can save a lot of your time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Click on the URL bar in your browser. (it should be editable now)&lt;br&gt;
&lt;strong&gt;Step 2:&lt;/strong&gt; Replace &lt;a href="https://github.com/"&gt;https://github.com/&lt;/a&gt; with &lt;a href="https://github1s.com/"&gt;https://github1s.com/&lt;/a&gt; and hit enter&lt;/p&gt;

&lt;p&gt;And that's it 🤯😲.&lt;/p&gt;

&lt;p&gt;now you can view all repo files and folders just like you view in your local vscode.&lt;/p&gt;

&lt;p&gt;Hope that helped you 😊&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>github</category>
      <category>visualstudiocode</category>
      <category>git</category>
    </item>
    <item>
      <title>Find out first unique element from array</title>
      <dc:creator>Indrakant Mishra</dc:creator>
      <pubDate>Fri, 29 Sep 2023 09:05:05 +0000</pubDate>
      <link>https://dev.to/indrakantm23/find-out-first-unique-element-from-array-5e7f</link>
      <guid>https://dev.to/indrakantm23/find-out-first-unique-element-from-array-5e7f</guid>
      <description>&lt;p&gt;Hello..., let's find how how we can find the unique element from an array from an unsorted array which has duplicate values -&lt;/p&gt;

&lt;p&gt;let's initialize an array -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a = [1,2,2,3,4,1,5,6,6,7]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and create a variable and initialize it with a[0] value -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let r = a[0]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now the main part, to iterate through array and find out the element with no duplicate value without creating any data structure and in single for loop -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for(let i=0; i&amp;lt;a.length; i++){
    r = r ^ a[i] 
    // here ^ is a bitwise XOR operator which gives a unique value. Here is how it works - if a value is same it gives 0 to it and if its a unique it returns 1 and for the value which is unique we get 1 and this is how we can find out unique element
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here is the complete code at one -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let a = [1,2,2,3,4,1,5,6,6,7]
let r = a[0]
for(let i=0; i&amp;lt;a.length; i++){
    r = r ^ a[i]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hope it helped you and you found it valuable.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>unique</category>
      <category>array</category>
    </item>
    <item>
      <title>Create a timer in React with Start, Pause and Reset feature</title>
      <dc:creator>Indrakant Mishra</dc:creator>
      <pubDate>Thu, 28 Sep 2023 03:03:48 +0000</pubDate>
      <link>https://dev.to/indrakantm23/create-a-timer-in-react-with-start-pause-and-reset-feature-1k40</link>
      <guid>https://dev.to/indrakantm23/create-a-timer-in-react-with-start-pause-and-reset-feature-1k40</guid>
      <description>&lt;p&gt;Hello guys, i came across this task during my interview with a great company so i thought to share it with you all. The task is to create a countdown timer in &lt;strong&gt;React&lt;/strong&gt; with &lt;em&gt;Start&lt;/em&gt;, &lt;em&gt;Pause&lt;/em&gt; and &lt;em&gt;Reset&lt;/em&gt; features, so let's start building it -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Import the useState hook from React for managing state
import { useState } from "react";

// Import the CSS file for styling
import "./styles.css";

// Define the main App component
export default function App() {
  // Initialize state variables for timer and timeInterval
  const [timer, setTimer] = useState(0);
  const [timeInterval, setTimeInterval] = useState(null);

  // Function to start the timer
  const startTimer = () =&amp;gt; {
    // Use setInterval to update the timer every 1000 milliseconds (1 second)
    setTimeInterval(setInterval(() =&amp;gt; {
      // Update the timer by incrementing the previous value by 1
      setTimer((prev) =&amp;gt; prev + 1);
    }, 1000));
  }

  // Function to pause the timer
  const pauseTimer = () =&amp;gt; {
    // Clear the interval to stop the timer from updating
    clearInterval(timeInterval);
  }

  // Function to reset the timer
  const resetTimer = () =&amp;gt; {
    // Reset the timer value to 0
    setTimer(0);
    // Clear the interval to stop the timer
    clearInterval(timeInterval);
  }

  // Render the timer and buttons in the component
  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h3&amp;gt;Timer: {timer}&amp;lt;/h3&amp;gt;
      &amp;lt;div className="btn-wrapper"&amp;gt;
        {/* Button to start the timer */}
        &amp;lt;button onClick={startTimer}&amp;gt;Start&amp;lt;/button&amp;gt;
        {/* Button to pause the timer */}
        &amp;lt;button onClick={pauseTimer}&amp;gt;Pause&amp;lt;/button&amp;gt;
        {/* Button to reset the timer */}
        &amp;lt;button onClick={resetTimer}&amp;gt;Reset&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the complete code, i hope you found it informative and you can extend it to next level by setting a timer and decreasing it until &lt;strong&gt;0&lt;/strong&gt;. See you soon in the next post 😊&lt;/p&gt;

</description>
      <category>timer</category>
      <category>react</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Built tic tac toe game using javascript</title>
      <dc:creator>Indrakant Mishra</dc:creator>
      <pubDate>Sat, 12 Aug 2023 12:09:19 +0000</pubDate>
      <link>https://dev.to/indrakantm23/built-tic-tac-toe-game-using-javascript-1i45</link>
      <guid>https://dev.to/indrakantm23/built-tic-tac-toe-game-using-javascript-1i45</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--60Unn-u4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rju0uf87nt3ibrq6se2b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--60Unn-u4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rju0uf87nt3ibrq6se2b.png" alt="Image description" width="800" height="682"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hello guys, if you like to try new stuffs in javascript and create something interesting this post is for you. Here we created a tictactoe game using javascript with little bit of UI designs.&lt;/p&gt;

&lt;p&gt;Try it here - &lt;a href="https://codepen.io/indrakantmishra/pen/bGQPOra"&gt;https://codepen.io/indrakantmishra/pen/bGQPOra&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope you like it :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tictactoe</category>
      <category>gamedev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Holi colors throw on click of screen</title>
      <dc:creator>Indrakant Mishra</dc:creator>
      <pubDate>Wed, 08 Mar 2023 07:18:59 +0000</pubDate>
      <link>https://dev.to/indrakantm23/holi-colors-throw-on-click-of-screen-3d8k</link>
      <guid>https://dev.to/indrakantm23/holi-colors-throw-on-click-of-screen-3d8k</guid>
      <description>&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/indrakantmishra/embed/JjarrqL?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>codepen</category>
    </item>
    <item>
      <title>Sort an array by boolean value</title>
      <dc:creator>Indrakant Mishra</dc:creator>
      <pubDate>Wed, 31 Aug 2022 19:08:26 +0000</pubDate>
      <link>https://dev.to/indrakantm23/sort-an-array-by-boolean-value-1j9d</link>
      <guid>https://dev.to/indrakantm23/sort-an-array-by-boolean-value-1j9d</guid>
      <description>&lt;p&gt;Hello guys, i hope you are doing really well and trying to solve bigger problems. But sometimes we get really difficult problem to solve in some interviews which can take our valuable chance 😥. Here we will be going through a problem to sort an array by boolean value without using any method and without creating and new array in O(n) time complexity.&lt;/p&gt;

&lt;p&gt;This problem was appeared in Amazon interview and i think this will be much useful for you. So let's start 😎 -&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let's assume we have an unsorted array like this -&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;const response = [&lt;br&gt;
    {&lt;br&gt;
        id: 1,&lt;br&gt;
        name: 'Phone',&lt;br&gt;
        isChecked: false&lt;br&gt;
    },&lt;br&gt;
    {&lt;br&gt;
        id: 2,&lt;br&gt;
        name: 'Laptop',&lt;br&gt;
        isChecked: true&lt;br&gt;
    },&lt;br&gt;
    {&lt;br&gt;
        id: 3,&lt;br&gt;
        name: 'Desktop',&lt;br&gt;
        isChecked: false&lt;br&gt;
    },&lt;br&gt;
    {&lt;br&gt;
        id: 4,&lt;br&gt;
        name: 'Watch',&lt;br&gt;
        isChecked: true&lt;br&gt;
    }&lt;br&gt;
];&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and we need to place all checked items first and unchecked items at last. Below is the code for 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 lastElementUnchecked;
for (let i = 0; i &amp;lt; response.length; i++) {
    if (response[i].isChecked &amp;amp;&amp;amp; lastElementUnchecked !== undefined) {
        let current = response[i];
        response[i] = response[lastElementUnchecked];
        response[lastElementUnchecked] = current;
        i = lastElementUnchecked;
        lastElementUnchecked = undefined;
    } else {
        if (!response[i].isChecked &amp;amp;&amp;amp; lastElementUnchecked === undefined) {
            lastElementUnchecked = i;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is very simple example to understand but while interviews it can be tough to reach over.&lt;/p&gt;

&lt;p&gt;I hope you like this, thank you for reading 😊 &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>sorting</category>
      <category>array</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to track browser tab / window switch event</title>
      <dc:creator>Indrakant Mishra</dc:creator>
      <pubDate>Wed, 22 Sep 2021 04:35:39 +0000</pubDate>
      <link>https://dev.to/indrakantm23/how-to-track-browser-tab-window-switch-event-36ii</link>
      <guid>https://dev.to/indrakantm23/how-to-track-browser-tab-window-switch-event-36ii</guid>
      <description>&lt;p&gt;Hello guys,&lt;/p&gt;

&lt;p&gt;In this article we will see how we can track the event of Tab/window change in browser. This method helps in tracking if user switches or navigates from your site to some other site.&lt;/p&gt;

&lt;p&gt;We can use an event listener to keep track of event change of tab switch which is &lt;code&gt;visibilitychange&lt;/code&gt;. Let's see it in code -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;document.addEventListener('visibilitychange', () =&amp;gt; {
    console.log('Current State: ', document.visibilityState)
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here if user switches to another tab or window we will get &lt;code&gt;hidden&lt;/code&gt; in console.log and if user comes back we will see &lt;code&gt;visible&lt;/code&gt; in console.log. By default the state will be &lt;code&gt;visible&lt;/code&gt; if user is on your website.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Hope you liked it, please mention in comment for any suggestions or feedback *&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>browser</category>
      <category>tabswitch</category>
      <category>windowswitch</category>
    </item>
    <item>
      <title>Method Chaining in JavaScript</title>
      <dc:creator>Indrakant Mishra</dc:creator>
      <pubDate>Tue, 10 Aug 2021 06:24:34 +0000</pubDate>
      <link>https://dev.to/indrakantm23/method-chaining-in-javascript-30dj</link>
      <guid>https://dev.to/indrakantm23/method-chaining-in-javascript-30dj</guid>
      <description>&lt;p&gt;Hello,&lt;br&gt;
In this article we will see how we can chain methods in javascript. This is most commonly asked questions in interviews for front end developers. An example of it could be &lt;code&gt;person.walks().talks().laughs().listens()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We can chain this till any level, let's see this in code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person{
    constructor(name){
        this.name = name;
    }
    walks(){
        console.log(this.name +' Walks')
        return this;
    }
    talks(){
        console.log(this.name +' Talks')
        return this;
    }
    laughs(){
        console.log(this.name +' Laughs')
        return this;
    }
}

let person = new Person('Person 1');
person.walks().talks().laughs();

//Output: 
Person 1 Walks
Person 1 Talks
Person 1 Laughs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;return this&lt;/code&gt; helps in chaining the methods which passes the complete object with all of it's prototypes and with that we can chain the methods.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Hope you liked it, please mention in comment for any suggestions or feedback *&lt;/em&gt;&lt;/p&gt;

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