<?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: Jahidul Islam (Saeid)</title>
    <description>The latest articles on DEV Community by Jahidul Islam (Saeid) (@jahidulsaeid).</description>
    <link>https://dev.to/jahidulsaeid</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%2F507982%2F8c7444e7-0310-4287-8efe-4755994d4746.jpeg</url>
      <title>DEV Community: Jahidul Islam (Saeid)</title>
      <link>https://dev.to/jahidulsaeid</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jahidulsaeid"/>
    <language>en</language>
    <item>
      <title>Supercharge Your Linux Shell with Zsh, zsh-autosuggestions, and PowerLevel10k</title>
      <dc:creator>Jahidul Islam (Saeid)</dc:creator>
      <pubDate>Thu, 12 Oct 2023 12:26:30 +0000</pubDate>
      <link>https://dev.to/jahidulsaeid/supercharge-your-linux-shell-with-zsh-zsh-autosuggestions-and-powerlevel10k-2cgl</link>
      <guid>https://dev.to/jahidulsaeid/supercharge-your-linux-shell-with-zsh-zsh-autosuggestions-and-powerlevel10k-2cgl</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;If you're a Linux enthusiast or someone who spends a significant amount of time in the terminal, you'll know the importance of a highly customizable and efficient shell. Zsh, or Z shell, is a powerful alternative to the default bash shell that offers a plethora of features and customizations. When combined with zsh-autosuggestions and the PowerLevel10k theme, you'll transform your command-line interface into a productivity powerhouse. In this guide, we'll walk you through the steps to configure Zsh with zsh-autosuggestions and the PowerLevel10k theme.&lt;/p&gt;

&lt;h2&gt;
  
  
  What You'll Need
&lt;/h2&gt;

&lt;p&gt;Before you get started, make sure you have the following prerequisites:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Linux-based system: This guide assumes you're running a Linux distribution, but the configurations can be adapted for other platforms.&lt;/li&gt;
&lt;li&gt;Zsh: You need to have Zsh installed. If it's not already installed, you can usually find it in your distribution's package manager. For example, on Debian/Ubuntu, you can run sudo apt-get install zsh, and on Fedora, you can use sudo dnf install zsh.&lt;/li&gt;
&lt;li&gt;Git: Ensure that Git is installed on your system, as we'll use it to download and update the PowerLevel10k theme.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Installing Zsh-autosuggestions
&lt;/h2&gt;

&lt;p&gt;Zsh-autosuggestions is a plugin that provides intelligent suggestions as you type, making your shell experience smoother and more efficient.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;First, you'll need to install a plugin manager for Zsh. We recommend using "Oh My Zsh" for its simplicity and extensive community support. To install "Oh My Zsh," run the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will automatically set Zsh as your default shell and install "Oh My Zsh."&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Once "Oh My Zsh" is installed, open your Zsh configuration file with your favorite text editor. The configuration file is usually located at ~/.zshrc. You can open it with the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;In your ~/.zshrc file, locate the plugins section and add zsh-autosuggestions to the list of plugins. It should look like this:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plugins=(zsh-autosuggestions)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Save and exit the file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reload your Zsh configuration to apply the changes:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Zsh-autosuggestions should now be active. You'll notice intelligent command suggestions as you type in your terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing PowerLevel10k Theme
&lt;/h2&gt;

&lt;p&gt;The PowerLevel10k theme is a highly customizable and visually appealing Zsh theme. It provides valuable information at a glance, making your command prompt more informative and stylish.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To install the PowerLevel10k theme, clone the Git repository into your Zsh custom themes directory. Use the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Open your ~/.zshrc file again:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nano ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Change the ZSH_THEME line to set your theme to PowerLevel10k:
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Save and exit the file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reload your Zsh configuration once more to apply the PowerLevel10k theme:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Upon restarting your Zsh session or opening a new terminal window, the PowerLevel10k theme will be active.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring PowerLevel10k
&lt;/h2&gt;

&lt;p&gt;The PowerLevel10k theme is highly customizable. To configure it to your liking, run the following command and follow the prompts:&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring PowerLevel10k
&lt;/h2&gt;

&lt;p&gt;The PowerLevel10k theme is highly customizable. To configure it to your liking, run the following command and follow the prompts:&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Font
&lt;/h2&gt;

&lt;p&gt;For p10k theme icon you can use &lt;a href="https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/FiraCode/Regular/FiraCodeNerdFont-Regular.ttf"&gt;FiraCode Nerd-font&lt;/a&gt;&lt;br&gt;
Download and install this font&lt;br&gt;
After that go to the terminal Preferences select Custom font: Select Firacode Nerd Font&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;You can choose various options for prompt styles, icons, and information displayed in your prompt.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By combining Zsh, zsh-autosuggestions, and the PowerLevel10k theme, you've transformed your Linux shell into a powerful, efficient, and visually pleasing environment. With intelligent suggestions, a customizable prompt, and a wealth of features, you'll take your command-line productivity to the next level. Enjoy your enhanced terminal experience!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Better Way to GitHub Commit: Simplify with a Custom .zshrc Function</title>
      <dc:creator>Jahidul Islam (Saeid)</dc:creator>
      <pubDate>Thu, 12 Oct 2023 10:24:43 +0000</pubDate>
      <link>https://dev.to/jahidulsaeid/a-better-way-to-github-commit-simplify-with-a-custom-zshrc-function-3kgb</link>
      <guid>https://dev.to/jahidulsaeid/a-better-way-to-github-commit-simplify-with-a-custom-zshrc-function-3kgb</guid>
      <description>&lt;p&gt;Version control systems like Git are essential tools for developers to track changes in their projects. Committing code changes with meaningful messages is crucial for maintaining a well-organized and easily navigable project history. While git commit -m works perfectly fine, there's a more engaging and efficient way to create commit messages using a custom script. In this blog, we'll explore how to create a custom GitHub commit script to enhance your version control workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem with Generic Commit Messages
&lt;/h2&gt;

&lt;p&gt;When you use git commit -m, you often end up with generic commit messages like "Fixed a bug" or "Updated code." These messages lack context and don't provide meaningful insights into the changes made, which can lead to confusion down the line. Additionally, it can be challenging to maintain a consistent commit message format across a development team, making collaboration more difficult.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simplifying GitHub Commits with a Custom .zshrc Function
&lt;/h2&gt;

&lt;p&gt;Firstly, you need to understand what the .zshrc file is. It's a configuration file for the Zsh shell, a powerful, highly customizable shell. You can use it to define custom functions and aliases, which can significantly improve your command-line experience.&lt;/p&gt;

&lt;p&gt;Here's the custom gitcommit function that you can add to your .zshrc file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gitcommit() {
    local commit_type
    PS3="Select a commit type: "

    local -A options=(
        [initial]="🎉 Initial commit"
        [feat]="✨ New Feature"
        [fix]="🐛 Fix Bug"
        [docs]="📚 Update Documentation"
        [refactor]="🔨 Refactor code"
        [perf]="🚀 Improves performance"
        [style]="💅 Style changes"
        # Add more if you want
    )

    select commit_type in "${(k)options[@]}"; do
        if [[ -n $commit_type ]]; then
            break
        else
            echo "Invalid option. Please select a valid commit type."
        fi
    done

    commit_hint=$options[$commit_type]

    print -n "Enter your commit message ($commit_hint): "
    read commit_message
    git add .
    git commit -m "${options[$commit_type]} - $commit_message"
}

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

&lt;/div&gt;



&lt;p&gt;This custom gitcommit function makes it easy and fun to commit your changes. Here's how it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You run the gitcommit command in your terminal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It presents you with a menu of commit types such as "Initial commit," "New Feature," "Fix Bug," and more. You can easily customize this list to match your project's needs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You select a commit type by entering the corresponding number.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You're prompted to enter your commit message, with a default hint based on the type you selected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The function stages all changes (with git add .) and commits them with a message in the format "Type - Your Message."&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By using this custom function, you not only streamline the commit process but also maintain a consistent and informative commit history. It ensures that you and your team can quickly understand the purpose of each commit without delving into the details of the changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Customizing the Commit Types
&lt;/h2&gt;

&lt;p&gt;In the custom &lt;code&gt;gitcommit&lt;/code&gt; function, you can easily customize the list of commit types to match your project's conventions. Simply edit the options associative array with the types and emojis you prefer. You can also add or remove types based on your needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Improving your GitHub commit workflow doesn't have to be a complicated process. By creating a custom function in your .zshrc file, you can simplify the commit process and ensure that your commit history is more informative and consistent. This is just one example of how you can enhance your development workflow with custom scripts and functions in your shell environment. Give it a try, and see how it makes your work on GitHub repositories more efficient and enjoyable. Happy coding! 🚀&lt;/p&gt;

</description>
      <category>github</category>
      <category>zsh</category>
    </item>
    <item>
      <title>How to paginated data in ant design table</title>
      <dc:creator>Jahidul Islam (Saeid)</dc:creator>
      <pubDate>Fri, 13 Jan 2023 12:04:50 +0000</pubDate>
      <link>https://dev.to/jahidulsaeid/how-to-paginated-data-in-ant-design-table-4cne</link>
      <guid>https://dev.to/jahidulsaeid/how-to-paginated-data-in-ant-design-table-4cne</guid>
      <description>&lt;p&gt;In Ant Design, you can use the &lt;code&gt;pagination&lt;/code&gt; attribute of the Table component to paginate data. &lt;/p&gt;

&lt;p&gt;And &lt;code&gt;onChange&lt;/code&gt; (callback function that gets called when the page number or page size changes).&lt;/p&gt;

&lt;p&gt;Here is an example of how to use the pagination attribute in a Table component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Table } from "antd";
import { useState, useEffect } from "react";
import axios from "axios";

function App() {
  const [dataSource, setDataSource] = useState([]);
  const [totalPassengers, setTotalPassengers] = useState(1);
  const [loading, setLoading] = useState(false);

  useEffect(() =&amp;gt; {
    fetchRecords(1, 10);
  }, []);
  const columns = [
    {
      title: "ID",
      dataIndex: "_id",
      key: "_id",
    },
    {
      title: "Name",
      dataIndex: "name",
      key: "name",
    },
    {
      title: "Trips",
      dataIndex: "trips",
      key: "trips",
    },
  ];

  const fetchRecords = (page, pageSize) =&amp;gt; {
    setLoading(true);
    axios
      .get(`https://api.instantwebtools.net/v1/passenger?page=${page}&amp;amp;size=${pageSize}`)
      .then((res) =&amp;gt; {
        setDataSource(res.data.data);
        setTotalPassengers(res.data.totalPassengers);
        setLoading(false);
      });
  };

  return (
    &amp;lt;div
      style={{
        display: "flex",
        justifyContent: "center",
        alignItems: "center",
      }}
    &amp;gt;
      &amp;lt;Table
        loading={loading}
        columns={columns}
        dataSource={dataSource}
        pagination={{
          total: totalPassengers,
          onChange: (page, pageSize) =&amp;gt; {
            fetchRecords(page, pageSize);
          },
        }}
        bordered
      &amp;gt;&amp;lt;/Table&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
export default App;

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

&lt;/div&gt;



&lt;p&gt;You can also use the pagination.total to set the total number of records&lt;/p&gt;

&lt;p&gt;Codesandbox Example : &lt;a href="https://codesandbox.io/s/tender-khorana-6oww0d"&gt;https://codesandbox.io/s/tender-khorana-6oww0d&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>antd</category>
      <category>pagination</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Next.js and Docker configuration</title>
      <dc:creator>Jahidul Islam (Saeid)</dc:creator>
      <pubDate>Mon, 09 Jan 2023 07:02:09 +0000</pubDate>
      <link>https://dev.to/jahidulsaeid/nextjs-and-docker-configuration-422d</link>
      <guid>https://dev.to/jahidulsaeid/nextjs-and-docker-configuration-422d</guid>
      <description>&lt;p&gt;To configure a Docker container for a Next.js application, you will need to create a &lt;code&gt;Dockerfile&lt;/code&gt; and a &lt;code&gt;docker-compose.yml&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Here is an example &lt;code&gt;Dockerfile&lt;/code&gt; that you can use as a starting point:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM node:latest

WORKDIR ./app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3000

CMD npm run dev

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

&lt;/div&gt;



&lt;p&gt;This &lt;code&gt;Dockerfile&lt;/code&gt; starts from the &lt;code&gt;node:latest&lt;/code&gt; base image, which is a latest version of Node.js. It then sets the working directory to /app and copies the &lt;code&gt;package.json&lt;/code&gt; file to the container. It runs &lt;code&gt;npm install&lt;/code&gt; to install the dependencies of the application. Finally, it copies the rest of the application code to the container and exposes the default Next.js port (3000) and runs the &lt;code&gt;npm run dev&lt;/code&gt; command to start the application in development mode.&lt;/p&gt;

&lt;p&gt;To build and run the container, you can use the following commands:&lt;br&gt;
&lt;/p&gt;

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

services:
  nextjs:
    ports:
      - 3000:3000
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - .:/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This &lt;code&gt;docker-compose.yml&lt;/code&gt; file defines a single service called &lt;code&gt;nextjs&lt;/code&gt;, which is built from the &lt;code&gt;Dockerfile&lt;/code&gt; in the current directory. It exposes the container's port 3000 on the host's port 3000 and mounts the current directory and the node_modules directory as volumes in the container. This allows you to make changes to the code and have them reflected in the running container without having to rebuild the image.&lt;/p&gt;

&lt;p&gt;To build and run the container, you can use the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;docker-compose build
&lt;span class="nv"&gt;$ &lt;/span&gt;docker-compose up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will build the service and start the container. You should then be able to access the Next.js application at &lt;code&gt;http://localhost:3000&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>ui</category>
      <category>design</category>
    </item>
    <item>
      <title>8 Tips and Tricks of JavaScript</title>
      <dc:creator>Jahidul Islam (Saeid)</dc:creator>
      <pubDate>Sat, 06 Nov 2021 18:23:37 +0000</pubDate>
      <link>https://dev.to/jahidulsaeid/8-tips-and-tricks-of-javascript-bgd</link>
      <guid>https://dev.to/jahidulsaeid/8-tips-and-tricks-of-javascript-bgd</guid>
      <description>&lt;h3&gt;
  
  
  1: How to remove falsy values from an array?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Remove falsy values from any array
let miscellaneous = ['🍎', false, '🍊', NaN, 0, undefined, '🌶️', null, '', '🥭'];

// passing Boolean to array.filter() will remove falsy values from array
let fruits = miscellaneous.filter(Boolean);

console.log(fruits); // ['🍎', '🍊', '🌶️', '🥭']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Boolean(expression) in JS returns true/false
Boolean(5 &amp;lt; 6); //  true
Boolean(100 &amp;gt; 200); // false
Boolean('JavaScript'); //true
Boolean(''); //false

// array example
let miscellaneous = ['🍎', false, '🍊', NaN];
let fruits = miscellaneous.filter(Boolean);

console.log(fruits); // ['🍎', '🍊']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2: How to convert any value to boolean?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Using !! in front of any value
console.log(!!"mashrafi"); // true
console.log(!!1); // true
console.log(!!0); // false
console.log(!!undefined); // false

// We can also use Boolean() to achieve same
console.log(Boolean("mashrafi")); // true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3: How to resize an array?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Resizing any array
let animals = ["🐕", "🐒", "🦊", "🐅"];

// We can use array's length property
animals.length = 3;

console.log(animals); // ["🐕", "🐒", "🦊"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4: How to flatten a multidimensional array?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// How to flattern a multi-dimensional array
let smileys = ['🥰', ['😄', '😃'], '😉', ['🥲', '😑']];

// We can use array.flat() method to flattern one level array
console.log(smileys.flat()); // ['🥰', '😄', '😃', '😉', '🥲', '😑']

// Multi level array
let smileys2 = ['🥰', ['😄', '😃', ['🥲', '😑']], '😉'];

// We can pass 'Infinity' parameter to array.flat function
console.log(smileys2.flat(Infinity)); // ['🥰', '😄', '😃', '🥲', '😑', '😉']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5: How to use short conditionals?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Short conditionals
const captain = "Mashrafi";

// Instead of doing this
if(captain === "Mashrafi") {
    console.log("❤️");
}

// We can use &amp;amp;&amp;amp;
captain === "Mashrafi" &amp;amp;&amp;amp; console.log("❤️");

// And instead of doing this
if(captain !== "Mashrafi") {
    console.log("😡");
}

// We can use ||
captain === "Mashrafi" || console.log("😡");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6: How to replace all occurrences of a string?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Replace all occurances of a string
const quote = "React is a JS framework &amp;amp; this framework is the most popular front-end framework right now";

// Replace all occurances of 'framework' with 'library'
console.log(quote.replace(/framework/g, "library")); // React is a JS library &amp;amp; this library is the most popular front-end library right now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7: How to log variables with values properly?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Log values with variable names smartly
const library1 = "jQuery";
const library2 = "React";

// Instead of doing this
console.log(`library1 - ${library1}`); // library1 - jQuery
console.log(`library2 - ${library2}`); // library2 - React

// We can do this
console.log({ library1 }); // {library1: 'jQuery'}
console.log({ library2 }); // {library2: 'React'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  8: How to Know performance of a task
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// We can wrap our task with performance.now()
const startTime = performance.now();

for(let i = 0; i &amp;lt;= 50; i++) {
    console.log(i);
}

const endTime = performance.now();

console.log(`loop took ${endTime - startTime} milliseconds to finish`);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thank you &lt;a href="https://www.youtube.com/channel/UCFM3gG5IHfogarxlKcIHCAg"&gt;Learn with Sumit Bangladesh&lt;/a&gt; for sharing amazing tutorials.&lt;br&gt;
Check you the Bangla tutorial &lt;a href="https://youtu.be/cdv4kM8MwsY?list=PLHiZ4m8vCp9NwCTJowt0HTCNRi5K6w4nv"&gt;#1 JavaScript Tips and Tricks - JavaScript Job Interview Questions - Bangla&lt;br&gt;
&lt;/a&gt; &lt;/p&gt;

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