<?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: Mahdi Falamarzi</title>
    <description>The latest articles on DEV Community by Mahdi Falamarzi (@mahdi_falamarzi).</description>
    <link>https://dev.to/mahdi_falamarzi</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%2F682446%2F78661ceb-36a0-4acd-b6c6-684eaeabf069.png</url>
      <title>DEV Community: Mahdi Falamarzi</title>
      <link>https://dev.to/mahdi_falamarzi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mahdi_falamarzi"/>
    <language>en</language>
    <item>
      <title>Exploring the Base64 Encoding and Decoding Functions in JavaScript: btoa() and atob()</title>
      <dc:creator>Mahdi Falamarzi</dc:creator>
      <pubDate>Thu, 13 Jul 2023 04:15:07 +0000</pubDate>
      <link>https://dev.to/mahdi_falamarzi/exploring-the-base64-encoding-and-decoding-functions-in-javascript-btoa-and-atob-31gk</link>
      <guid>https://dev.to/mahdi_falamarzi/exploring-the-base64-encoding-and-decoding-functions-in-javascript-btoa-and-atob-31gk</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;br&gt;
In JavaScript, the btoa() and atob() global functions are essential tools for handling Base64 encoding and decoding. The btoa() function allows you to create a Base64-encoded ASCII string from a binary string, treating each character as a byte of binary data. On the other hand, the atob() function decodes a Base64-encoded string back into its original form. This article delves into the syntax, usage, and examples of these functions, emphasizing their significance in JavaScript development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encoding with btoa():&lt;/strong&gt;&lt;br&gt;
The btoa() method enables the conversion of a binary string into a Base64-encoded ASCII string. It is particularly useful for encoding data that may encounter communication problems during transmission. By employing the btoa() function, you can encode various types of information, including control characters represented by ASCII values ranging from 0 to 31.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decoding with atob():&lt;/strong&gt;&lt;br&gt;
The atob() function acts as the counterpart to btoa(), allowing you to decode a Base64-encoded string back into its original binary representation. By utilizing atob(), you can reliably retrieve encoded data and restore it to its original form.&lt;/p&gt;

&lt;p&gt;Example Usage:&lt;br&gt;
Let's explore an example to illustrate the usage of btoa() and atob() functions in JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const encodedData = btoa("Hello, world"); // 'SGVsbG8sIHdvcmxk'
const decodedData = atob(encodedData); // "Hello, world"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code snippet, we start by utilizing the btoa() function to encode the string "Hello, world." The resulting Base64-encoded data is stored in the variable encodedData. Subsequently, we employ the atob() function to decode the encodedData, and the original string "Hello, world" is obtained and stored in the decodedData variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
The btoa() and atob() global functions in JavaScript are invaluable tools for handling Base64 encoding and decoding. With btoa(), you can encode binary strings into Base64-encoded ASCII strings, while atob() allows for the reverse process of decoding Base64-encoded strings back to their original form. Understanding and utilizing these functions empower front-end developers to work with encoded data, enabling reliable transmission and retrieval of information. Be mindful of the limitations when working with Unicode strings, and refer to appropriate resources to address such scenarios effectively.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>encode</category>
      <category>decode</category>
      <category>base64</category>
    </item>
    <item>
      <title>How to render conditional items in React?</title>
      <dc:creator>Mahdi Falamarzi</dc:creator>
      <pubDate>Thu, 06 Jul 2023 03:55:25 +0000</pubDate>
      <link>https://dev.to/mahdi_falamarzi/how-to-render-conditional-items-in-react-1h1o</link>
      <guid>https://dev.to/mahdi_falamarzi/how-to-render-conditional-items-in-react-1h1o</guid>
      <description>&lt;p&gt;&lt;strong&gt;Comparing Three Approaches to Render conditional items in React&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When it comes to rendering conditional in a React, there are multiple approaches you can take. In this article, we will explore three different methods and identify the best approach among them. Suppose we have an array of objects and want to condition render items in three ways.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const data = [
  {
    id: 1,
    name: "john",
  },
  {
    id: 2,
    name: "jack",
  },
  {
    id: 3,
    name: "mike",
  },
  {
    id: 4,
    name: "stephen",
  },
];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;if else Statements&lt;/strong&gt;&lt;br&gt;
In the first approach, items are rendered using a series of conditional statements. Each item in the data array is checked for a specific name and mapped to its corresponding emoji. While this method works, it can become hard to maintain and extend as the number of name and conditions increase.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const result = data.map((item) =&amp;gt; {
  if (item.name === "john") {
    return "😀";
  } else if (item.name === "jack") {
    return "🕵️‍";
  } else if (item.name === "mike") {
    return "🤶";
  } else if (item.name === "stephen") {
    return "🎅";
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Switch Statements&lt;/strong&gt;&lt;br&gt;
The second approach utilizes a switch statement to map names to emojis. This method provides a cleaner and more readable syntax compared to the first approach. Switch statements are especially useful when there are multiple cases to handle. However, as the number of emojis grows, the switch statement can become lengthy and harder to manage.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const result = data.map((item) =&amp;gt; {
  switch (item.name) {
    case "john":
      return "😀";
    case "jack":
      return "🕵️‍";
    case "mike":
      return "🤶";
    case "stephen":
      return "🎅";
  }
});

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Object Mapping&lt;/strong&gt;&lt;br&gt;
The third and best approach involves creating an object mapping the names to emojis. Each name is associated with its respective emoji in the nameMap object. This approach is concise, scalable, and easy to maintain. By utilizing the object mapping technique, we eliminate the need for lengthy conditional or switch statements, resulting in cleaner code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const nameMap = {
  john: "😀",
  jack: "🕵️‍",
  mike: "🤶",
  stephen: "🎅",
};

const result = data.map((item) =&amp;gt; nameMap[item.name]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The benefits of the third approach include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simplicity: The code is cleaner and easier to read, understand, and maintain.&lt;/li&gt;
&lt;li&gt;Scalability: Adding or modifying emojis is straightforward as we only need to update the nameMap object.&lt;/li&gt;
&lt;li&gt;Performance: Object lookups in JavaScript are generally faster compared to multiple conditionals or switch statements.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The nameMap object provides a direct mapping between names and emojis, allowing for efficient retrieval of emojis based on the item's name. This approach promotes code reusability and enhances the overall maintainability of the component.&lt;/p&gt;

&lt;p&gt;In conclusion, the third approach, utilizing object mapping, is the recommended method for rendering emojis in React components. It offers simplicity, scalability, and improved performance compared to conditional statements and switch statements. By adopting this approach, developers can write clean, maintainable code that efficiently handles emoji rendering in their applications.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>map</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to detect an active internet connection in JavaScript apps?</title>
      <dc:creator>Mahdi Falamarzi</dc:creator>
      <pubDate>Wed, 28 Jun 2023 17:51:09 +0000</pubDate>
      <link>https://dev.to/mahdi_falamarzi/how-to-detect-an-active-internet-connection-in-javascript-apps-3a6a</link>
      <guid>https://dev.to/mahdi_falamarzi/how-to-detect-an-active-internet-connection-in-javascript-apps-3a6a</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
In today's interconnected world, understanding and adapting to the network connectivity status of web browsers are vital for delivering optimal user experiences. This article explores two key features that facilitate this process: the property &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine"&gt;Navigator.onLine&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API"&gt;Network Information API&lt;/a&gt;. By leveraging these capabilities, web developers can make informed decisions, dynamically adjust content delivery, and provide real-time feedback to users based on their network connectivity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Navigator.onLine Property: Checking Browser Connectivity&lt;/strong&gt;&lt;br&gt;
The Navigator.onLine property serves as a convenient method to determine the online status of a web browser. This property returns a boolean value, where true indicates that the browser is online, and false indicates that it is offline. Updates to the onLine property occur whenever the browser's ability to connect to the network changes. For instance, if a user follows links or a script requests a remote page, the onLine property will accurately reflect the corresponding status.&lt;br&gt;
It's important to note that different browsers may implement this property differently, resulting in varying behavior and potential false positives or false negatives. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Network Information API: Enhanced Connectivity Insights&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Check &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API"&gt;mdn web docs&lt;/a&gt; for browser compatibility&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To gain deeper insights into the user's network connection, developers can utilize the Network Information API in conjunction with the onLine property. The Network Information API provides information about the system's connection, including general connection types such as 'wifi', 'cellular', and more. Accessing this API through the Navigator.connection property allows developers to obtain detailed information about the connection type and tailor their applications accordingly.&lt;br&gt;
For instance, by combining the onLine property with the Network Information API, developers can dynamically adjust content delivery based on the user's connection capabilities. They can selectively preload resources for faster connections, deliver low-definition content for slower connections, or provide offline-friendly interfaces when the browser is offline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Listening for Network State Changes&lt;/strong&gt;&lt;br&gt;
In addition to retrieving the current online status, developers can monitor changes in the network state by listening to the online and offline events. These events are triggered when the browser's connectivity status changes. By subscribing to these events, developers can execute specific actions or update the user interface based on the browser's online or offline status.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementing Real-Time Network State Updates&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;// Check you are online or not
if (navigator.onLine) {
  console.log("online");
} else {
  console.log("offline");
}

// To see changes in the network state, use addEventListener
window.addEventListener("offline", (e) =&amp;gt; {
  console.log("offline");
});

window.addEventListener("online", (e) =&amp;gt; {
  console.log("online");
});

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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;If you have a React app you can use this hook.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;navigator.connection&lt;/code&gt; maybe does not work on your browser check &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API"&gt;mdn web docs&lt;/a&gt; for browser compatibility&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;import { useEffect, useState } from "react";

const useNetworkInformation = () =&amp;gt; {
  const [networkState, setNetworkState] = useState({
    isOnline: navigator.onLine,
    effectiveType: "",
    downlink: 0,
    rtt: 0,
  });

  useEffect(() =&amp;gt; {
    const updateNetState = () =&amp;gt; {
      const connection = navigator.connection;
      if (connection) {
        setNetworkState({
          isOnline: navigator.onLine,
          effectiveType: connection.effectiveType,
          downlink: connection.downlink,
          rtt: connection.rtt,
        });
      }
    };
    window.addEventListener("load", updateNetState);
    window.addEventListener("online", updateNetState);
    window.addEventListener("offline", updateNetState);

    return () =&amp;gt; {
      window.removeEventListener("load", updateNetState);
      window.removeEventListener("online", updateNetState);
      window.removeEventListener("offline", updateNetState);
    };
  }, []);

  return networkState;
};

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Understanding and adapting to the network connectivity status of web browsers are paramount for delivering optimal user experiences. The Navigator.onLine property provides a straightforward approach to determine the browser's online or offline status, although careful consideration is required due to browser-specific behaviors. To gain deeper insights and tailor content delivery based on connection types, developers can leverage the Network Information API through the Navigator.connection property. By combining these features and listening for network state changes, developers can create dynamic and responsive applications that provide an exceptional browsing experience across diverse network environments.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>internet</category>
      <category>api</category>
    </item>
    <item>
      <title>How to read CSV files in the typescript react app?</title>
      <dc:creator>Mahdi Falamarzi</dc:creator>
      <pubDate>Tue, 19 Jul 2022 05:35:30 +0000</pubDate>
      <link>https://dev.to/mahdi_falamarzi/how-to-read-csv-file-in-typescript-react-app-106h</link>
      <guid>https://dev.to/mahdi_falamarzi/how-to-read-csv-file-in-typescript-react-app-106h</guid>
      <description>&lt;p&gt;A comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format. A CSV file typically stores tabular data (numbers and text) in plain text, in which case each line will have the same number of fields. &lt;a href="https://en.wikipedia.org/wiki/Comma-separated_values" rel="noopener noreferrer"&gt;Wiki&lt;/a&gt;&lt;br&gt;
In this article, we want to read a CSV file in react application and for this, we use Papa Parse  package. Papa Parse is the fastest in-browser CSV (or delimited text) parser for JavaScript.&lt;br&gt;
Let's div in. First, we should install the package.&lt;/p&gt;

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

npm install papaparse


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

&lt;/div&gt;

&lt;p&gt;while this project is created with typescript we should install the typescript package.&lt;/p&gt;

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

npm install @types/papaparse –-save-dev


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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;One important thing about the CSV files in react app that is the CSV file should be copied to the public directory.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fscnuqn66849fsyf4i4fl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fscnuqn66849fsyf4i4fl.png" alt="copy csv file in public directory"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then we must import Papa Parse.&lt;/p&gt;

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

import Papa, { ParseResult } from "papaparse"


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

&lt;/div&gt;

&lt;p&gt;ParseResult is papaparse type for result.&lt;br&gt;
Then we define type of data.&lt;/p&gt;

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

type Data = {
  name: string
  family: string
  email: string
  date: string
  job: string
}

type Values = {
  data: Data[]
}


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

&lt;/div&gt;

&lt;p&gt;after that, we create the state.&lt;/p&gt;

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

const [values, setValues] = React.useState&amp;lt;Values | undefined&amp;gt;()


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

&lt;/div&gt;

&lt;p&gt;and create a function for getting csv file with Papa Parse package.&lt;/p&gt;

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

const getCSV = () =&amp;gt; {
    Papa.parse("/file.csv", {
      header: true,
      download: true,
      skipEmptyLines: true,
      delimiter: ",",
      complete: (results: ParseResult&amp;lt;Data&amp;gt;) =&amp;gt; {
        setValues(results)
      },
    })
  }


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

&lt;/div&gt;

&lt;p&gt;and put it in useEffect hook.&lt;/p&gt;

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

 React.useEffect(() =&amp;gt; {
    getCSV()
  }, [])


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

&lt;/div&gt;

&lt;p&gt;That’s it. But for re-usability and separation of concerns reasons, we can create a custom hook.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F75ky9eo5f58nurj3oq6g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F75ky9eo5f58nurj3oq6g.png" alt="useReadCSV custom hook"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  conclusion
&lt;/h1&gt;

&lt;p&gt;Reading and importing CSV files into the application is a challenge. In this article, we use Papa Parse. This is a great package for importing, reading, etc... CSV files in js applications. For more information about this package see the blog &lt;a href="https://www.papaparse.com" rel="noopener noreferrer"&gt;Papa Parse&lt;/a&gt;.   &lt;/p&gt;

</description>
      <category>typescript</category>
      <category>react</category>
      <category>javascript</category>
      <category>npm</category>
    </item>
    <item>
      <title>How to iterate through objects in javascript?</title>
      <dc:creator>Mahdi Falamarzi</dc:creator>
      <pubDate>Wed, 23 Feb 2022 12:31:18 +0000</pubDate>
      <link>https://dev.to/mahdi_falamarzi/how-to-iterate-through-objects-5g3i</link>
      <guid>https://dev.to/mahdi_falamarzi/how-to-iterate-through-objects-5g3i</guid>
      <description>&lt;p&gt;&lt;strong&gt;Iterables&lt;/strong&gt;&lt;br&gt;
It's a kind of new mechanism to iterate or traverse through data structures.&lt;br&gt;
As you know Arrays, String, Maps and Sets or other similar collections are already iterable (it means we can use for of loop to iterate them) but objects are not.&lt;/p&gt;

&lt;p&gt;when running the below code we had an error that &lt;br&gt;
&lt;code&gt;TypeError: obj is not iterable&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;How to create an iterator?&lt;/strong&gt;&lt;br&gt;
The "[Symbol.iterator]" method must be implemented which should return an iterator object that should have a next() method that returns the object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to create an iterator with generator function?&lt;/strong&gt;&lt;br&gt;
In this example, we implement "[Symbol.iterator]" with generator function!&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Although you can iterate through an object with "for in" or "Object.entries", "Object.keys" and "Object.values" (convert to array and iterate on them) but in this article, we introduce a new way to iterate objects with "[Symbol.iterate]" and function generator.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Prettier vs ESLint</title>
      <dc:creator>Mahdi Falamarzi</dc:creator>
      <pubDate>Mon, 17 Jan 2022 16:17:34 +0000</pubDate>
      <link>https://dev.to/mahdi_falamarzi/prettier-vs-eslint-hhi</link>
      <guid>https://dev.to/mahdi_falamarzi/prettier-vs-eslint-hhi</guid>
      <description>&lt;p&gt;&lt;strong&gt;Prettier&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---NQbZ7P3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctsvitfi85rhjpflyyjk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---NQbZ7P3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ctsvitfi85rhjpflyyjk.jpg" alt="Image description" width="640" height="400"&gt;&lt;/a&gt;&lt;br&gt;
Prettier is an opinionated code formatter with support for many languages such as Javascript and many other languages.&lt;br&gt;
In fact, this tool removes all original styling and ensures that all outputted code conforms to a consistent style. Prettier takes your code and reprints it from scratch by taking the line length into account.&lt;/p&gt;

&lt;p&gt;Suppose you have a function that receives 4 arguments.&lt;/p&gt;

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

&lt;p&gt;You agree, it is not very attractive if you are lucky like me and uses this tool, the code will be much more beautiful&lt;/p&gt;

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

&lt;p&gt;This tool has a configuration file in which the entire code profile is customizable.&lt;/p&gt;

&lt;p&gt;Why should every developer use Prettier?&lt;br&gt;
    - Building and enforcing a style guide&lt;br&gt;
    - Helping Newcomers&lt;br&gt;
    - Writing code&lt;br&gt;
    - Easy to adopt&lt;br&gt;
    - Clean up an existing codebase&lt;br&gt;
    - Ride the hype train&lt;br&gt;
    - Supports many languages&lt;br&gt;
    - Integrates with most editors&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ESLint&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--puYWkR3N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/myui49so86pooxsrntlx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--puYWkR3N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/myui49so86pooxsrntlx.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;br&gt;
But the hand ESLint is a static code analysis tool for identifying problematic patterns found in JavaScript code. It was created by Nicholas C. Zakas in 2013. Rules in ESLint are configurable, and customized rules can be defined and loaded. ESLint covers both code quality and coding style issues. ESLint supports current standards of ECMAScript and experimental syntax from drafts for future standards. Code using JSX or TypeScript can also be processed when a plugin or transpiler is used. in another word ESLint Find and fixes problems in your JavaScript/Typescript code.&lt;br&gt;
The above description is taken from Wikipedia, which clearly explains the work of ESLint. ESLint requires Node.js and works on Windows, Mac and Linux.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GYoGGi8h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fh6vosflauesgyu53ts1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GYoGGi8h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fh6vosflauesgyu53ts1.jpg" alt="Image description" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Prettier is a style code formatter that support many languages but ESLint is a tool that finds javascript/typescript issue and gives some special hint to solve them.&lt;/p&gt;

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