<?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: kheersagar parja</title>
    <description>The latest articles on DEV Community by kheersagar parja (@kheersagar).</description>
    <link>https://dev.to/kheersagar</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%2F964217%2F7f2e7ad7-8751-42c0-b46f-86299bdbf6eb.jpeg</url>
      <title>DEV Community: kheersagar parja</title>
      <link>https://dev.to/kheersagar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kheersagar"/>
    <language>en</language>
    <item>
      <title>Tailwind + React Native</title>
      <dc:creator>kheersagar parja</dc:creator>
      <pubDate>Wed, 28 Dec 2022 16:35:29 +0000</pubDate>
      <link>https://dev.to/kheersagar/tailwind-react-native-59d3</link>
      <guid>https://dev.to/kheersagar/tailwind-react-native-59d3</guid>
      <description>&lt;h2&gt;
  
  
  1. Create the project
&lt;/h2&gt;

&lt;p&gt;Create the project with the Expo CLI&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-expo-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Install &lt;code&gt;tailwind&lt;/code&gt; and its dependency
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add nativewind
yarn add --dev tailwindcss
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Setup Tailwind CSS
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;npx tailwindcss init&lt;/code&gt; to create a tailwind.config.js file&lt;/p&gt;

&lt;p&gt;Add the paths to all of your component files in your tailwind.config.js file. Remember to replace  with the actual name of your directory e.g. screens.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// tailwind.config.js

module.exports = {
- content: [],
+ content: ["./App.{js,jsx,ts,tsx}", "./&amp;lt;custom directory&amp;gt;/**/*.{js,jsx,ts,tsx}"],
  theme: {
    extend: {},
  },
  plugins: [],
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Add the Babel plugin
&lt;/h2&gt;

&lt;p&gt;Modify your &lt;code&gt;babel.config.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// babel.config.js
module.exports = function (api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
+   plugins: ["nativewind/babel"],
  };
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import { Text, View } from 'react-native';

export default function App() {
  return (
   &amp;lt;View className="flex-1 items-center justify-center bg-white"&amp;gt;
      &amp;lt;Text&amp;gt;Open up App.js to start working on your app!&amp;lt;/Text&amp;gt;
    &amp;lt;/View&amp;gt;
  );
}


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

&lt;/div&gt;



</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>Update State After API Response React!!!</title>
      <dc:creator>kheersagar parja</dc:creator>
      <pubDate>Thu, 24 Nov 2022 12:01:11 +0000</pubDate>
      <link>https://dev.to/kheersagar/update-state-after-api-response-react-2jo1</link>
      <guid>https://dev.to/kheersagar/update-state-after-api-response-react-2jo1</guid>
      <description>&lt;h2&gt;
  
  
  Have you ever wounder why immediately after updating the state if it is logged, value is undefined??
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const fetchAPI = async () =&amp;gt; {
    const res = await axios.get("https://catfact.ninja/fact");
    setData((previousData) =&amp;gt; ({ ...previousData, ...res.data }));
    console.log("response from API: \n" + res.data.fact);
    console.log("State Data: \n" + data.fact);
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Console
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
response from API: 
The smallest wildcat today is the Black-footed cat. The females are less than 20 inches (50 cm) long and can weigh as little as 2.5 lbs (1.2 kg). 

State Data: 
undefined 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Whole Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import axios from "axios";
import { useEffect, useState } from "react";
import "./styles.css";

export default function App() {
  const [data, setData] = useState({});
  const [count, setCount] = useState(0);
  const fetchAPI = async () =&amp;gt; {
    const res = await axios.get("https://catfact.ninja/fact");
    setData((previousData) =&amp;gt; ({ ...previousData, ...res.data }));
    console.log("response from API: \n" + res.data.fact);
    console.log("State Data: \n" + data.fact);
    if (data.fact) {
      setCount(data.fact.length);
    }
  };

  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Hello CodeSandbox&amp;lt;/h1&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;h1&amp;gt;Fact:&amp;lt;/h1&amp;gt;
        &amp;lt;h2&amp;gt;{data.fact}&amp;lt;/h2&amp;gt;
        &amp;lt;h2&amp;gt;charact count : {count}&amp;lt;/h2&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;button onClick={fetchAPI}&amp;gt;fetch API&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Refer video below:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flszdcptog454np56vo0x.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flszdcptog454np56vo0x.gif" alt="Image description" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;On clicking Fetch Api Button&lt;br&gt;
State is not updated immediately and if following code is dependent, then it does work.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Its because how react updates the state and re-renders&lt;/strong&gt;&lt;br&gt;
React update state in batches, means It will register the update state function in a queue and after running all the code it executes the state queue and re-renders.&lt;br&gt;
That's why if we log just after setData() function we get undefined but if we click on &lt;strong&gt;fetch api button again&lt;/strong&gt; we get &lt;u&gt;previous value&lt;/u&gt;. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For more information how react updates state &lt;a href="https://beta.reactjs.org/learn/queueing-a-series-of-state-updates" rel="noopener noreferrer"&gt;[click here]&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  How to fix this and execute code as soon as state is updated?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Fix: UseEffect&lt;/strong&gt;&lt;br&gt;
It takes a callback function and a dependency array, this can be used to fix the problem of running dependent code after state is updated&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; {
    console.log("updated DATA \n" + data.fact);
    setCount(0); // to eleminate race condition
    if (data.fact) {
      setCount(data.fact.length);
    }
  }, [data]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Whole Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import axios from "axios";
import { useEffect, useState } from "react";
import "./styles.css";

export default function App() {
  const [data, setData] = useState({});
  const [count, setCount] = useState(0);
  const fetchAPI = async () =&amp;gt; {
    const res = await axios.get("https://catfact.ninja/fact");
    setData((previousData) =&amp;gt; ({ ...previousData, ...res.data }));
    console.log("response from API: \n" + res.data.fact);
  };
  useEffect(() =&amp;gt; {
    console.log("updated DATA \n" + data.fact);
    if (data.fact) {
      setCount(data.fact.length);
    }
  }, [data]);

  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;h1&amp;gt;Hello CodeSandbox&amp;lt;/h1&amp;gt;
      &amp;lt;div&amp;gt;
        &amp;lt;h1&amp;gt;Fact:&amp;lt;/h1&amp;gt;
        &amp;lt;h2&amp;gt;{data.fact}&amp;lt;/h2&amp;gt;
        &amp;lt;h2&amp;gt;charact count : {count}&amp;lt;/h2&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;button onClick={fetchAPI}&amp;gt;fetch API&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc1z7fpdb2vyjtgjgx4xj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc1z7fpdb2vyjtgjgx4xj.gif" alt="Image description" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Regular Function VS Fat Arrow Function</title>
      <dc:creator>kheersagar parja</dc:creator>
      <pubDate>Wed, 23 Nov 2022 06:29:01 +0000</pubDate>
      <link>https://dev.to/kheersagar/regular-function-vs-fat-arrow-function-5c14</link>
      <guid>https://dev.to/kheersagar/regular-function-vs-fat-arrow-function-5c14</guid>
      <description>&lt;h2&gt;
  
  
  Regular function
&lt;/h2&gt;



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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inside traditonal function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Arrow Function or Fat Arrow function
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const AFatArrowFunc = () =&amp;gt;{
  console.log("inside fatArrowFunc function")
}
AFatArrowFunc()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inside fatArrowFunc function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Both behaved the same then what is the difference??&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  If we call both functions before its initialization what will happen?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ATraditionalFunc()
AFatArrowFunc()
function ATraditionalFunc () {
  console.log("inside traditonal function")
}
const AFatArrowFunc = () =&amp;gt;{
  console.log("inside fatArrowFunc function")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8zptdofka1kyv5gqsw7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa8zptdofka1kyv5gqsw7.png" alt="Image description" width="800" height="62"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We got a Reference Error, why did it happened?&lt;br&gt;
There are two reasons :&lt;/p&gt;
&lt;h2&gt;
  
  
  Hoisting
&lt;/h2&gt;

&lt;p&gt;JavaScript Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables or classes to the top of their scope, prior to execution of the code.&lt;br&gt;
for more information: [&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Hoisting#:~:text=JavaScript%20Hoisting%20refers%20to%20the,defined%20in%20the%20ECMAScript%20specification." rel="noopener noreferrer"&gt;click here&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wy5pdzguz2knq2tr82d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wy5pdzguz2knq2tr82d.png" alt="test" width="800" height="196"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;When Execution is in Line no. 1&lt;/strong&gt;&lt;br&gt;
Regular function in allocated memory in Global scope whereas Fat Arrow function in allocation in Script scope. Therefore when we try to access a function before its Initialization it gives us reference error.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If hoisting is the only reason then, what happens if we do this ?&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ATraditionalFunc()
AvarfatArrowFunc() 
function ATraditionalFunc () {
  console.log("inside traditonal function")
}

var AvarfatArrowFunc = () =&amp;gt;{
  console.log("inside varfatArrowFunc function")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpwph452ce3hvzh6x8jmf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpwph452ce3hvzh6x8jmf.png" alt="Image description" width="800" height="76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;we changed const to var and output is still the same.&lt;br&gt;
Here comes how JavaScript treats variables and functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Value initialization
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5tp9uxoug9u239crw8m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh5tp9uxoug9u239crw8m.png" alt="Image description" width="800" height="179"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;when JavaScript allocates memory it assign undefined to Fat Arrow function because JS treats it as a variable  and whole function to Regular function, refer above image.&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Block scope Vs Global scope var, let, const !!!</title>
      <dc:creator>kheersagar parja</dc:creator>
      <pubDate>Tue, 22 Nov 2022 08:51:46 +0000</pubDate>
      <link>https://dev.to/kheersagar/block-scope-vs-global-scope-var-let-const--454j</link>
      <guid>https://dev.to/kheersagar/block-scope-vs-global-scope-var-let-const--454j</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const a = 1;
let b = 2;
var c = 3;

if(true){
  const a = 10
  let b = 20
  var c  = 30
  console.log('Inside Block value of a = ' ,a ) 
  console.log('Inside Block value of b = ' ,b ) 
  console.log('Inside block value of c = ' ,c ) 
}
console.log('Outside Block value of a = ' ,a ) 
console.log('Outside Block value of b = ' ,b ) 
console.log('Outside block value of c = ' ,c ) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Inside Block value of a =  10
Inside Block value of b =  20
Inside block value of c =  30
Outside Block value of a =  1
Outside Block value of b =  2
Outside block value of c =  30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why did value of a and b are unchanged outside the block??
&lt;/h2&gt;

&lt;p&gt;The answer is let and const are block scope.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When Execution is in Line no. 1&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BET_QPS6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fw65p6kwvcs0lzwb7ix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BET_QPS6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fw65p6kwvcs0lzwb7ix.png" alt="" width="880" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;var &lt;strong&gt;c&lt;/strong&gt; is allocated memory in Global Scope whereas &lt;strong&gt;a&lt;/strong&gt; and &lt;strong&gt;b&lt;/strong&gt; are allocated memory in different scope.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;When Execution reached to Line no.6&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6hKocXYS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/muqcogc8wb6dj30qu0sz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6hKocXYS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/muqcogc8wb6dj30qu0sz.png" alt="" width="880" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Values of variables are assigned but, a new scope can been seen, Block Scope where again &lt;strong&gt;a&lt;/strong&gt; and &lt;strong&gt;b&lt;/strong&gt; are allocated memory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;When Execution reached to line no. 9&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T8U9sB9E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rn8glfttexbhcgrbzkp0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T8U9sB9E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rn8glfttexbhcgrbzkp0.png" alt="" width="880" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Variables values are assigned in block scope and we can notice Script scoped &lt;strong&gt;a&lt;/strong&gt; and &lt;strong&gt;b&lt;/strong&gt; is not changed but global scoped variable c is changed to 30.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;When Execution reached to Line no. 13 outside if block&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--twGBbdgA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0nv8ufv2d2qvv0n3x6r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--twGBbdgA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0nv8ufv2d2qvv0n3x6r.png" alt="" width="880" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Work of block scope is done and variable a and b values remains unchanged whereas value of c is changed.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Asynchronous to Synchronous JavaScript</title>
      <dc:creator>kheersagar parja</dc:creator>
      <pubDate>Tue, 22 Nov 2022 07:19:27 +0000</pubDate>
      <link>https://dev.to/kheersagar/asynchronous-to-synchronous-javascript-3ml5</link>
      <guid>https://dev.to/kheersagar/asynchronous-to-synchronous-javascript-3ml5</guid>
      <description>&lt;h2&gt;
  
  
  Popular JavaScript Interview Question
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How to Convert Asynchronous code to Synchronous code ?&lt;/strong&gt;&lt;br&gt;
Promises can be used to convert Asynchronous code to Synchronous code.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Example&lt;br&gt;
&lt;strong&gt;Asynchronous setTimeout Function&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("Before setTimeout")

setTimeout(()=&amp;gt;{
    console.log("Inside setTimeout")
},1000)

console.log("After setTimeout")

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before setTimeout
After setTimeout
Inside setTimeout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Convert Asynchronous setTimeout Function to Synchronous&lt;/strong&gt;&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("Before setTimeout")

//await will wait for JS to resolve the promise
await new Promise((resolve,reject)=&amp;gt;{
   setTimeout(()=&amp;gt;{
   //after 1000ms promise will be resolved
    resolve(console.log("Inside setTimeout")) 
   },1000) 
})

console.log("After setTimeout")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Before setTimeout
Inside setTimeout
After setTimeout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>interview</category>
    </item>
    <item>
      <title>Plotting 100k+ records in JavaScript</title>
      <dc:creator>kheersagar parja</dc:creator>
      <pubDate>Mon, 21 Nov 2022 06:22:36 +0000</pubDate>
      <link>https://dev.to/kheersagar/plotting-100k-records-in-javascript-2ja5</link>
      <guid>https://dev.to/kheersagar/plotting-100k-records-in-javascript-2ja5</guid>
      <description>&lt;p&gt;Unlike matplot library in python where you can easily plot records of &lt;strong&gt;100k+&lt;/strong&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Many JavaScript Library Fails to do the same&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Popular JS Library
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.chartjs.org/"&gt;Chart.js&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://apexcharts.com/"&gt;ApexChart.js&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;They are good and easy to use but when it comes to plotting data over 30k+ or 50k+ they suffer performance issue and can even crash.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Both have configuration to speedup the performance and plot larger dataset but they still suffer.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Apache ECharts
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;JavaScript library can easily plot data over 100k+&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;Reference Link: &lt;a href="https://echarts.apache.org/handbook/en/get-started/"&gt;Apache ECharts&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Examples
&lt;/h2&gt;

&lt;p&gt;Reference Link: &lt;a href="https://echarts.apache.org/examples/en/editor.html?c=area-simple"&gt;link&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>python</category>
      <category>webdev</category>
      <category>graph</category>
    </item>
  </channel>
</rss>
