<?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: Muslimat Mojeed </title>
    <description>The latest articles on DEV Community by Muslimat Mojeed  (@symplymuslimah12).</description>
    <link>https://dev.to/symplymuslimah12</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%2F1370050%2F0b8be9e4-84e6-49f3-9c7c-f4cebeabfa2a.jpeg</url>
      <title>DEV Community: Muslimat Mojeed </title>
      <link>https://dev.to/symplymuslimah12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/symplymuslimah12"/>
    <language>en</language>
    <item>
      <title>Why I want to be a Frontend Developer and How HNG Will Help Me Achieve My Goals</title>
      <dc:creator>Muslimat Mojeed </dc:creator>
      <pubDate>Thu, 30 Jan 2025 18:54:35 +0000</pubDate>
      <link>https://dev.to/symplymuslimah12/why-i-want-to-be-a-frontend-developer-and-how-hng-will-help-me-achieve-my-goals-40gd</link>
      <guid>https://dev.to/symplymuslimah12/why-i-want-to-be-a-frontend-developer-and-how-hng-will-help-me-achieve-my-goals-40gd</guid>
      <description>&lt;p&gt;After surveying several niches, I came to the conclusion that front-end development would be the best fit for me. But how did I come to that conclusion? 🤔&lt;br&gt;
I engaged in a two-week session on front-end development and was fascinated by how code could be interpreted by the browser, transforming into stunning websites.  &lt;/p&gt;

&lt;p&gt;The desire to acquire a skill and become rich within a few months initially attracted me to tech. However, after a few months, I realized I had to let go of the unrealistic expectation of getting rich quickly. I initially thought front-end development was easy, but I soon discovered there was much more to it.  &lt;/p&gt;

&lt;p&gt;As I progressed in my career pursuit in both front-end development and Physiotherapy, I realized how I could actually use these skills to solve problems in the healthcare space. My enthusiasm for combining tech and health grew stronger, further fueling my zeal to become a developer—probably not just a front-end developer in the coming years. I’m staying motivated to learn these skills and apply them in the real world, if God permits.  &lt;/p&gt;

&lt;h2&gt;
  
  
  How HNG Will Help Me Achieve My Goals as a Front-End Developer
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Mentorship sessions, advice from experts, and webinars  that will prepare me for the future.&lt;/li&gt;
&lt;li&gt;Gaining real-world experience is another key aspect. I hope to work on real-world projects, collaborate with others in the tech space, and improve my skills.
&lt;/li&gt;
&lt;li&gt;Networking with like-minded people to grow and learn.
&lt;/li&gt;
&lt;li&gt;Building teamwork and strong communication skills.
&lt;/li&gt;
&lt;li&gt;Get updates on the latest technologies and learning how to evolve and grow in the tech space.
&lt;/li&gt;
&lt;li&gt;Most importantly, discover the best way to prepare for interviews and get hired as a &lt;a href="https://hng.tech/hire/reactjs-developers" rel="noopener noreferrer"&gt;React&lt;/a&gt; or &lt;a href="https://hng.tech/hire/javascript-developers" rel="noopener noreferrer"&gt;JavaScript&lt;/a&gt; developer.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  My Goals
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I recently picked up React and would like to build real-world projects using this technology.
&lt;/li&gt;
&lt;li&gt;Build my portfolio and update my resume.
&lt;/li&gt;
&lt;li&gt;Gain hands-on experience.
&lt;/li&gt;
&lt;li&gt;Work on projects and brainstorm ideas with teammates.
&lt;/li&gt;
&lt;li&gt;Gain experience working in teams.
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How Do I Plan to Achieve Them?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Actively contributing to projects, webinars, and other engaging sessions.
&lt;/li&gt;
&lt;li&gt;Being open to corrections in projects, writing, and other areas.
&lt;/li&gt;
&lt;li&gt;Continuously showing up and staying consistent.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you HNG for the opportunity to be part of this.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>5 Common Mistakes When Using useEffect Hook in React</title>
      <dc:creator>Muslimat Mojeed </dc:creator>
      <pubDate>Thu, 30 Jan 2025 18:46:41 +0000</pubDate>
      <link>https://dev.to/symplymuslimah12/5-common-mistakes-when-using-useeffect-hook-in-react-949</link>
      <guid>https://dev.to/symplymuslimah12/5-common-mistakes-when-using-useeffect-hook-in-react-949</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Errors are inevitable in coding but can be avoided or managed. Bugs can be easily identified when encountered with a proper understanding of good coding practices.&lt;br&gt;
One aspect where errors often arise is when using the &lt;code&gt;useEffect&lt;/code&gt; Hook, typically due to mistakes made by some developers. &lt;br&gt;
In this article, I will briefly discuss what &lt;code&gt;useEffect&lt;/code&gt; entails, the common mistakes and best practices, and when to use the &lt;code&gt;useEffect&lt;/code&gt; Hook. &lt;br&gt;
You should be familiar with React and &lt;code&gt;useEffect&lt;/code&gt; Hooks before reading this article.  Whether you're just starting with React Hooks or you've been using them for a while, this article is for you.  &lt;/p&gt;

&lt;p&gt;What is useEffect?&lt;br&gt;
&lt;code&gt;useEffect(function () { }, []);&lt;/code&gt;&lt;br&gt;&lt;br&gt;
&lt;code&gt;useEffect&lt;/code&gt; is a hook that allows us to handle a side effect. &lt;br&gt;
Literally, side effects involve interactions between a React component and the world outside the component.&lt;br&gt;&lt;br&gt;
For example, fetching data from a server into your component is a side effect because there's an interaction between the server and the React component. The &lt;code&gt;useEffect&lt;/code&gt; Hook serves as a connection between the two, allowing us to manage side effects efficiently.&lt;br&gt;&lt;br&gt;
It is a great Hook that helps prevent infinite re-fetching, ensuring data is fetched once after the component mounts.  &lt;/p&gt;
&lt;h2&gt;
  
  
  Definition of Key Terms
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Dependency Array&lt;/strong&gt; (&lt;code&gt;[]&lt;/code&gt;): This is an empty array that ensures fetched data runs only when the component renders for the first time. Infinite loops is halted using the dependency array.
&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Cleanup Function&lt;/strong&gt;: In React, a cleanup function helps manage side effects effectively. The cleanup function resets a state/element back to its previous state, allowing developers to clean up resources such as canceling API requests, clearing timers, or removing event listeners. This prevents the persistence of certain actions and ensures optimal performance.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  5 Common Mistakes
&lt;/h2&gt;

&lt;p&gt;1.&lt;strong&gt;Missing Dependency Array&lt;/strong&gt;:&lt;br&gt;
Without a dependency array, data will be re-fetched after every render. HTTP requests will be sent to the server on every render, causing an infinite loop.&lt;br&gt;
&lt;strong&gt;Example&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;Import {useEffect} from 'react';
function App(){
//Incorrect 
 useEffect(function () {
//Your Logic here }) 

//Correct 
useEffect(function () {
//Your Logic here }, [])
return &amp;lt;p&amp;gt; Hey Effects&amp;lt;/p&amp;gt;;
}
export default App;

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

&lt;/div&gt;



&lt;p&gt;2.&lt;strong&gt;Incorrect or Missing Properties in the Dependency Array&lt;/strong&gt;:&lt;br&gt;
React would not be aware of any state variable or prop used inside an effect if it is not included in the dependency array. This could lead to a bug called &lt;strong&gt;"stale closure"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stale Closure&lt;/strong&gt;: A stale closure happens when a function remembers old values from its surrounding code instead of the most recent ones. Imagine React remembering the initial state or props but failing to recognize updates after each state change.&lt;br&gt;
&lt;strong&gt;Example&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;//Incorrect
import { useState, useEffect } from 'react';

function App() {
  const [count, setCount] = useState(0);

  useEffect(() =&amp;gt; {
    //Your logic here
  }, []);

 return &amp;lt;button&amp;gt;Increment&amp;lt;/button&amp;gt;;
}

&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;//correct
import { useState, useEffect } from 'react';

function App() {
  const [count, setCount] = useState(0);

  useEffect(() =&amp;gt; {
    //Your logic here
  }, [count]);

 return &amp;lt;button&amp;gt;Increment&amp;lt;/button&amp;gt;;
}

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

&lt;/div&gt;



&lt;p&gt;3.&lt;strong&gt;Overusing an Effect&lt;/strong&gt;:&lt;br&gt;
Writing excessive logic within a single &lt;code&gt;useEffect&lt;/code&gt; is a bad practice.&lt;br&gt;&lt;br&gt;
   Additionally, the &lt;code&gt;useEffect&lt;/code&gt; Hook has its specific purpose in React. Using &lt;code&gt;useEffect&lt;/code&gt; for actions that can be handled manually or with other hooks is considered a bad practice.&lt;br&gt;&lt;br&gt;
Overusing it can degrade performance, cause issues during cleanup, and introduce unnecessary bugs that might be difficult to identify.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Example&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;import { useState, useEffect } from 'react';

function App() {
  const [data, setData] = useState(null);
  const [count, setCount] = useState(0);

  // Incorrect
  useEffect(() =&amp;gt; {
    // Fetching data
    fetch('/api/data')
      .then(response =&amp;gt; response.json())
      .then(data =&amp;gt; setData(data));

    // Setting up a timer
    const timer = setInterval(() =&amp;gt; {
      setCount(prevCount =&amp;gt; prevCount + 1);
    }, 1000);

    // Cleanup function
    return () =&amp;gt; clearInterval(timer);
  }, []);

  return &amp;lt;div&amp;gt;{ data and count}&amp;lt;/div&amp;gt;;
}
&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;//Correct
import { useState, useEffect } from 'react';

function App() {
  const [data, setData] = useState(null);
  const [count, setCount] = useState(0);

  // Fetching data
  useEffect(() =&amp;gt; {
    fetch('/api/data')
      .then(response =&amp;gt; response.json())
      .then(data =&amp;gt; setData(data));
  }, []);

  // Setting up a timer
  useEffect(() =&amp;gt; {
    const timer = setInterval(() =&amp;gt; {
      setCount(prevCount =&amp;gt; prevCount + 1);
    }, 1000);

    return () =&amp;gt; clearInterval(timer);
  }, []);

  return &amp;lt;div&amp;gt;{data and count }&amp;lt;/div&amp;gt;;
}


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

&lt;/div&gt;



&lt;p&gt;4.&lt;strong&gt;Not Cleaning Up Effects&lt;/strong&gt;:&lt;br&gt;
Side effects (e.g., fetching data from an API) could persist after the component has been re-rendered or unmounted, causing performance issues like memory leaks or unnecessary data fetching.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Incorrect
import { useState, useEffect } from 'react';

function App() {
  [count,setCount] = useState(0);

  // Setting up a timer
  useEffect(() =&amp;gt; {
    const timer = setInterval(() =&amp;gt; {
      setCount(prevCount =&amp;gt; prevCount + 1);
    }, 1000);
}, []);

 return &amp;lt;div&amp;gt;{ data and count 
}&amp;lt;/div&amp;gt;;
}
&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;//Correct
import { useState, useEffect } from 'react';

function App() {
  const [count, setCount] = useState(0);

  useEffect(() =&amp;gt; {
    const timer = setInterval(() =&amp;gt; {
      setCount(prevCount =&amp;gt; prevCount + 1);
    }, 1000);

//Clean-up function 
    return () =&amp;gt; clearInterval(timer);
  }, []);

 return &amp;lt;div&amp;gt;{data and count}&amp;lt;/div&amp;gt;;
}

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

&lt;/div&gt;



&lt;p&gt;5.&lt;strong&gt;Storing useEffect in a Variable&lt;/strong&gt;: &lt;br&gt;
Storing a &lt;code&gt;useEffect&lt;/code&gt; function in a variable can lead to loss of effect execution and stale closure.&lt;br&gt;&lt;br&gt;
If you store the effect function in a variable without calling it inside the &lt;code&gt;useEffect&lt;/code&gt;, the side effect will not execute, leading to unintended behavior in your component.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Example&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;import { useEffect } from 'react';

function App() {
  // Incorrect 
 const effectData = function () {
       //Your logic here
     };

  useEffect(effectData
, []);

  return &amp;lt;div&amp;gt;Data...&amp;lt;/div&amp;gt;;
}
&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;//Correct
import { useEffect } from 'react';

function App() {
  useEffect(function () { 
       //Your Logic here
     }, []);

 return &amp;lt;div&amp;gt;Data..&amp;lt;/div&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Always add the dependency array to avoid infinite loops.&lt;/li&gt;
&lt;li&gt;Add state or props you're currently using within the effect to the dependency array to avoid stale closure.&lt;/li&gt;
&lt;li&gt;Avoid writing excessive logic within a single useEffect. Use multiple hooks to maintain good practices.&lt;/li&gt;
&lt;li&gt;Use the useEffect Hook for its intended purpose such as setting up timers, subscriptions, fetching data, etc.&lt;/li&gt;
&lt;li&gt;Ensure you clean up functions to avoid memory leaks or performance-related issues.&lt;/li&gt;
&lt;li&gt;Don't store useEffect or effect functions in a variable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Being mindful of these mistakes and following good practices while coding prevent unnecessary errors that could delay productivity.&lt;br&gt;
This article has explored the common mistakes in useEffect and its best practices.&lt;br&gt;
I hope you found the article insightful.&lt;br&gt;
Have you encountered any mistakes aside from the ones mentioned above? Drop them in the comment box!&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>15 Essential JavaScript Concepts To Learn Before Starting React</title>
      <dc:creator>Muslimat Mojeed </dc:creator>
      <pubDate>Tue, 03 Dec 2024 03:06:39 +0000</pubDate>
      <link>https://dev.to/symplymuslimah12/15-essential-javascript-concepts-to-learn-before-starting-react-1ggl</link>
      <guid>https://dev.to/symplymuslimah12/15-essential-javascript-concepts-to-learn-before-starting-react-1ggl</guid>
      <description>&lt;p&gt;React is a popular Javascript library used to build real-world applications. To become a proficient React developer, understanding some fundamental Javascript concepts is important. For many, learning React can seem difficult, but understanding these basic concepts could ease one's learning process.&lt;br&gt;
In this article, I will cover 15 essential concepts every developer should know before starting React. Each concept is explained with an example to show it's importance.&lt;br&gt;
If you're just starting with React or you're about to explore the library, this article is for you.&lt;/p&gt;
&lt;h2&gt;
  
  
  15 Essential JavaScript Concepts
&lt;/h2&gt;

&lt;p&gt;1.&lt;strong&gt;Callback Function&lt;/strong&gt;&lt;br&gt;
Functions are the building blocks of any program that allows code to be called multiple times without repetition.&lt;br&gt;
One type of function is the &lt;strong&gt;Callback Function&lt;/strong&gt;.&lt;br&gt;
If you want a user to click on an arrow in the browser before any information is displayed or want some codes to be executed right after you're done fetching data from API, you can utilize the power of callbacks. &lt;br&gt;
The callback function performs its task after a function or an event occurs and allows control over the execution of a function.&lt;br&gt;
 It's a function passed as an argument to another function and used to specify what should occur after the completion of an asynchronous operation or an event.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// The callback function
function showText() {
  console.log('The written text should show after 2 seconds.');
}
 function showAfterDelay(callback, delay) {
  setTimeout(callback, delay);
}
showAfterDelay(showText, 2000);

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

&lt;/div&gt;


&lt;p&gt;2.&lt;strong&gt;Arrow Functions&lt;/strong&gt;&lt;br&gt;
Arrow Functions was introduced in ES6 and allows function syntax to be written more concisely. The arrow function are widely used in React due to its conciseness.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const showText = () =&amp;gt; {
  console.log('This written text should show after 2 seconds.');
};
const showAfterDelay = (callback, delay) =&amp;gt; {
  setTimeout(callback, delay);
};
showAfterDelay(showText, 2000);

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

&lt;/div&gt;


&lt;p&gt;3.&lt;strong&gt;Array.Map() Method&lt;/strong&gt;&lt;br&gt;
Mutating the existing array is commonly discouraged in React as it could result in unnecessary bugs and performance issues. For that reason, developers employ the array methods. The functional array methods don't mutate the original array rather return a new array from the existing one.&lt;br&gt;
One of the functional array methods is the &lt;strong&gt;Array.map()&lt;/strong&gt; method.&lt;br&gt;
 &lt;strong&gt;Array.map()&lt;/strong&gt; methods loop over an existing array and return a new array with the same length. Changes can be made to the new array without having any effect on the existing one.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Const BookNumbers = [1,2,3,4];
Const DoubleNumbers = BookNumbers.map((book)=&amp;gt; book *2);
Console.log(DoubleNumbers);
//Output BookNumbers= [2,4,6,8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;4.&lt;strong&gt;Array.Filter() Method&lt;/strong&gt;&lt;br&gt;
The &lt;strong&gt;Array.filter()&lt;/strong&gt; method works in an interesting and logical way. These methods can be used to filter out some elements of the array based on a true or false condition. &lt;br&gt;
When a statement is false, it automatically gets filtered out and when it is true, it keeps it making it a suitable approach for removing unwanted elements from an array.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Const BookNumbers = [1,2,3,4];
Const FilteredNumbers = BookNumbers.filter((book) =&amp;gt; book % 2 !== 0 );
Console.log(FilteredNumbers);
// Output 1,3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;5.&lt;strong&gt;Array.reduce() Method&lt;/strong&gt;&lt;br&gt;
As the name implies, &lt;strong&gt;array.reduce()&lt;/strong&gt; method reduces an entire array to a single value. It's one of the best methods of summing or grouping elements of an array.&lt;/p&gt;
&lt;h2&gt;
  
  
  3 Important Keywords in Reduce Method
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The initial Value (optional)&lt;/strong&gt;: A starting value for the accumulator. If not provided, the first array element is used as the initial value, and the iteration starts from the second element.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accumulator (required):&lt;/strong&gt;The accumulated result from previous iterations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Current Value( required)&lt;/strong&gt;: The current element being processed.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const BookNumbers = [1, 2, 3, 4];
const NumberSum = BookNumbers.reduce((accumulator, currentValue) =&amp;gt; accumulator + currentValue, 0);

console.log(sum); // Output: 15
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;6.&lt;strong&gt;Template Literals&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Template literals&lt;/strong&gt; allow strings to contain Javascript variables or any JavaScript expression.&lt;br&gt;
It provides a simple approach to create strings in JavaScript using the backticks and dollar with curly braces ${}.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Const NameValue = "Ade";
const NumValue = 5;
const TempLit= `I am ${NameValue}, a ${NumValue} year old girl `
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;7.&lt;strong&gt;Ternary operators&lt;/strong&gt; &lt;br&gt;
&lt;strong&gt;Ternary operators&lt;/strong&gt; are conditional operators that offer a simple and concise way of writing an if..else statement.&lt;br&gt;
React doesn't directly support the if..else statement as it isn't suitable for the syntax expression known as &lt;strong&gt;JSX&lt;/strong&gt; that exists in React.&lt;br&gt;
&lt;strong&gt;JSX&lt;/strong&gt; is a syntax extension of JavaScript that allows the embedding of Javascript, CSS and React Component into HTML.&lt;br&gt;
React Syntax is considered more as an expression than a statement and the ternary serves as the suitable operator for it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const BookNumbers = 4;
const result = (BookNumbers % 2 === 0) ? "Even" : "Odd";
console.log(result); 
// Output: "Even"

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

&lt;/div&gt;


&lt;p&gt;8.&lt;strong&gt;Short-circuiting and Logical operators&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Logical operators&lt;/strong&gt; are used to combine multiple conditions into a single expression. The main logical operators that exist in JavaScript are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AND- returns true only if both operands are true.&lt;/li&gt;
&lt;li&gt;OR- returns true if at least one operand is true.&lt;/li&gt;
&lt;li&gt;NOT- invert true values of its operand..&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Short-circuiting&lt;/strong&gt; is a behavior that occurs in logical operators where, under specific conditions, the second operand is not evaluated because the result of the entire expression can be determined solely by the first operand.&lt;/p&gt;
&lt;h2&gt;
  
  
  How Short-circuiting works
&lt;/h2&gt;

&lt;p&gt;AND (&amp;amp;&amp;amp;)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if the first operand is false, the entire expression is false, so the second operand is not assessed.&lt;/li&gt;
&lt;li&gt;if the first operand is true, the second operand is assessed to determine the value that will be returned.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OR (||)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;if the first operand is true, the entire expression is true, so the second operand isn't evaluated.&lt;/li&gt;
&lt;li&gt;if the operand is false, the second operand is assessed to determine the value to be returned.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const idVerify = true;
const displayMessage = idVerify &amp;amp;&amp;amp; "Identified";

console.log(displayMessage); 
// Output: "Identified"

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

&lt;/div&gt;


&lt;p&gt;9.&lt;strong&gt;RestSpread Operator&lt;/strong&gt;&lt;br&gt;
In instances when you want to add a new property to an existing array or merge a group of existing arrays, the spread Operator is the go-to operator.&lt;br&gt;
&lt;strong&gt;Spread Operator&lt;/strong&gt; (...) denoted by 3 dots expands an array into individual elements and is used at the beginning of an array. It is used to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Merge array
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const OriginalArray1 = [1, 2, 3];
const OriginalArray2 = [4, 5, 6];

const MergedArray = [...array1, ...array2];

console.log(MergedArray); 
// Output: [1, 2, 3, 4, 5, 6]

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Copy array
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const originalArray = [1, 2, 3];
const copiedArray = [...originalArray];

console.log(copiedArray); 
// Output: [1, 2, 3]

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;add a new property to an existing array
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const users = [
  { name: "John", age: 20},
];
const updatedUsers = users.map(user =&amp;gt; ({ ...user, id: 001 }));

console.log(updatedUsers);
/*
Output:
[
  { name: "John", age: 20, id : 001 },
]
*/

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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;pass an argument to a function
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [2, 4, 6];
const maxNumber = Math.max(...numbers);

console.log(maxNumber); 
// Output: 6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Rest Operator&lt;/strong&gt;(...) is also denoted with the 3 dots but written at the end of an array. It is used to collect multiple properties from a destructured object/array.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Const BookNumbers= [1,2,3,4,5];
const [first, second, ...rest] = BookNumbers;

console.log(first);  // Output: 1
console.log(second); // Output: 2
console.log(rest);   // Output: [3, 4, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;10.&lt;strong&gt;Optional chaining&lt;/strong&gt;&lt;br&gt;
Optional chaining handles null or undefined values in an easy way. It is used to access properties or any intermediate properties that appears to be null or undefined in the chain. It will automatically be short-circuited and rendered undefined. Ideally, without &lt;strong&gt;optional chaining&lt;/strong&gt;, it returns an error.&lt;br&gt;
In some instances you're not sure all the values exist in an object, consider using optional chaining as it is a syntax that offers checks for null and undefined values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const user = {
  name: "John",
  World() {
    return "Hello World!";
  }
};

const greeting = user.greet?.();
console.log(greeting); 
 // Output: "Hello World!"

const farewell = user.farewell?.();
console.log(farewell); // Output: undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;11.&lt;strong&gt;Destructuring Array&lt;/strong&gt;&lt;br&gt;
Codes can become cumbersome when multiple properties have to be called at once from an array. With destructuring, this can be prevented.&lt;br&gt;
Destructuring allows assembling values from an array into a distinct variable.&lt;br&gt;
Destructuring can be used to&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Skip an element&lt;/li&gt;
&lt;li&gt;Nest elements&lt;/li&gt;
&lt;li&gt;Set default values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An essential concept that shouldn't be ignored before start React is Destructuring.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Const Book = [ 
{title: 'Everyday Smile', 
Author: 'Pitty Butter'}
];
Const [title, author] = book;
Console.log(title);
 //Output Everyday Smile
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;12.&lt;strong&gt;Working With Immutable Arrays&lt;/strong&gt;&lt;br&gt;
Arrays can be mutated in JavaScript meaning properties can be added, removed or updated in an array.&lt;br&gt;
However, in React, immutability is often preferred to preserve state integrity and ensure React can detect changes. To work with immutable arrays in React, methods like &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;filter&lt;/code&gt;, and the spread operator are commonly used for adding, deleting, and updating items in arrays without mutating the original array.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Adding an item
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Book = [ 
  { title: 'Everyday Smile', author: 'Pitty Butter' }
]; 
const newBook = [
  { title: 'Love', author: 'Pascal Rowland' }
];
// Combining two arrays immutably
const addBook = [...newBook, ...Book];
console.log(addBook);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To delete an item
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const idToDelete = 1;
const books = [
  { id: 1, title: 'Everyday Smile', author: 'Pitty Butter' },
  { id: 2, title: 'Love', author: 'Pascal Rowland' }
];

// Using filter to remove a book by ID
const updatedBooks = books.filter((book) =&amp;gt; book.id !== idToDelete);

console.log(updatedBooks);
//Output [
  { id: 2, title: 'Love', author: 'Pascal Rowland' }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To update an item
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const idToUpdate = 1;
const books = [
  { id: 1, title: 'Everyday Smile', author: 'Pitty Butter' },
  { id: 2, title: 'Love', author: 'Pascal Rowland' }
];

// Using map to update a book by ID
const updatedBooks = books.map((book) =&amp;gt;
  book.id === idToUpdate ? { ...book, author: 'Pit Bren' } : book
);

console.log(updatedBooks);
//Output [
  { id: 1, title: 'Everyday Smile', author: 'Pit Bren' },
  { id: 2, title: 'Love', author: 'Pascal Rowland' }
]

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

&lt;/div&gt;



&lt;p&gt;13.&lt;strong&gt;Async/await function&lt;/strong&gt;&lt;br&gt;
Async JavaScript governs how tasks that take time to complete are being performed. JavaScript is a synchronous language i.e runs a code one after the other in a single thread.&lt;br&gt;
In instances when you're fetching data from a database, some codes may be required to load before the fetching is completed.&lt;br&gt;
With the async function, code can be executed without waiting for the operations to complete, thus improving user experience and overall performance.&lt;br&gt;
In React, you'll frequently work with Application Programming Interface (API), thus, it is important have insight into how this function works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function fetchData(){
Const res = await fetch(https://api.example.com);
Const data = await res.json();
return data;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;14.&lt;strong&gt;Promises&lt;/strong&gt;&lt;br&gt;
Promises refers to built-in object that represents the eventual completion or failure of an asynchronous operation.&lt;br&gt;
Promises exist in one of the three states:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pending: Initial state, neither fulfilled nor rejected.&lt;/li&gt;
&lt;li&gt;Fulfilled: operation completed successfully&lt;/li&gt;
&lt;li&gt;Rejected: The operation encountered an error. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Promises play a significant role in JavaScript, which makes it an important concept to learn about. It enables you to write cleaner code, systematically handle errors and boost overall performance.&lt;/p&gt;

&lt;p&gt;15.&lt;strong&gt;Handling Errors using try.catch.finally&lt;/strong&gt;&lt;br&gt;
There are moments when errors pop up during data fetching leaving you pondering on how to find or fix these bugs.&lt;br&gt;
With the use of the keywords, data fetching is handled in a more structured way.&lt;br&gt;
Try..catch..finally block is a powerful error handling construct in JavaScript, that allows potential errors to be handled successfully and specific codes to be executed regardless of whether an error occurs.&lt;br&gt;
It could be time-consuming to find certain errors in your code. By utilizing these blocks, it becomes easy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Try- Encloses the code that might throw an error.&lt;/li&gt;
&lt;li&gt;Catch- execute if an error is thrown within the try block. Receives error objects as an argument.&lt;/li&gt;
&lt;li&gt;Finally - Execute regardless of whether an error occurs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function fetchData() {
  try {
    const res = await fetch("https://API.example.com");
    if (!res.ok) {
      throw new Error("Error fetching data");
    }
    const data = await res.json();
    console.log(data);
  } catch (error) {
    console.error(error.message);
  } finally {
    console.log("Fetching completed");
  }
}
fetchData();

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

&lt;/div&gt;



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

&lt;p&gt;Gaining insights into the essential JavaScript concepts explained above will ease one's learning process and guide you toward becoming a proficient React developer.If you haven’t learned these concepts yet, make an effort to do so. Feel free to share your suggestions in the comment section!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Vite VS Create-React-App - What you need to know</title>
      <dc:creator>Muslimat Mojeed </dc:creator>
      <pubDate>Sat, 02 Nov 2024 18:44:11 +0000</pubDate>
      <link>https://dev.to/symplymuslimah12/vite-vs-create-react-app-what-you-need-to-know-3mad</link>
      <guid>https://dev.to/symplymuslimah12/vite-vs-create-react-app-what-you-need-to-know-3mad</guid>
      <description>&lt;p&gt;Over the years, &lt;strong&gt;Create-React-App(CRA)&lt;/strong&gt; has been a go-to tool for building React applications.&lt;br&gt;
&lt;strong&gt;Create-React-App&lt;/strong&gt; is a popular command line tool that help developers quickly set up and build single-page React applications, especially for applications that don't require advanced customization. It solved the challenges of needing to set up React from scratch or writing React manually. &lt;/p&gt;

&lt;p&gt;However, &lt;strong&gt;Create-React-App(CRA)&lt;/strong&gt; still relies on slow and traditional technologies, making it more suitable for building smaller projects.&lt;br&gt;
Building large modern real-world applications requires fast and modern technologies that improve the entire front-end development experience. This is where &lt;strong&gt;Vite&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vite&lt;/strong&gt; is a modern build tool that contains templates of frameworks, including React, for setting up projects. It offers a faster development and deployment process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vite&lt;/strong&gt; is a tool that addresses the major setbacks of the &lt;strong&gt;Create-React-App(CRA)&lt;/strong&gt;. It has gained popularity among developers and is now a recommended tool for building modern real-world applications.&lt;br&gt;
 &lt;br&gt;
&lt;em&gt;A study showed that build time is 4 times, development time is 15 times, and hot reloading time is 10 times faster for the React application built with Vite than the application built with CRA (Gurung, Bhabishya, 2024).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You might be wondering—why is it recommended for modern real-world applications? What features makes it different from CRA?&lt;br&gt;
 &lt;br&gt;
This article has answers to these questions. While various tools for setting up React exist, this article aims to explore the built-in features of &lt;strong&gt;Vite&lt;/strong&gt; that makes it a preferred choice, the differences between CRA and &lt;strong&gt;Vite&lt;/strong&gt;, and the steps for setting up &lt;strong&gt;Vite&lt;/strong&gt; using Node Package Manager (NPM).&lt;/p&gt;

&lt;p&gt;Whether you're just starting with &lt;strong&gt;React&lt;/strong&gt;, you want to switch to Vite or have an insight on what this tool is all about. This article is for you.&lt;/p&gt;
&lt;h2&gt;
  
  
  Built-in features of Vite
&lt;/h2&gt;

&lt;p&gt;The features of Vite majorly focus on speed, configuration and flexibility.&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%2Fxcorhipo2psxgqmogeiu.jpeg" 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%2Fxcorhipo2psxgqmogeiu.jpeg" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;br&gt;
Here are some of the key built-in features in Vite:&lt;br&gt;
 &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fast Hot Module Replacement (HMR):&lt;/strong&gt;&lt;br&gt;
HMR is a development feature that allows update to module—which means small pieces of code, each managing a specific functionality in an application—to be introduced into a running application without a full reload of the browser.Vite has a fast Hot Module Replacement (HMR), enabling changes to appear on the browser instantly, thus speeding up development. &lt;br&gt;
For instance, if you update the code in a module, Vite only reloads that modified module, not all the modules.&lt;br&gt;
&lt;strong&gt;Create-React-App (CRA)&lt;/strong&gt;, on the other hand, relies on bundler that packages files together. All modules need to be compiled and bundled using the Webpack bundler before changes are seen in the browser, often leading to slower updates when working on  large projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use of native ES Modules:&lt;/strong&gt; &lt;br&gt;
Native ES modules are a standardized way to organize JavaScript code, introduced in ES6. They allow developers to structure code into separate modules that can be imported and exported, supporting reusability. &lt;br&gt;
Vite uses native ES Modules, serving the modules directly to the browser without any initial bundling. Browsers can load modules independently as changes are made, thus speeding up development process.&lt;br&gt;
 &lt;br&gt;
&lt;strong&gt;Create React App (CRA)&lt;/strong&gt; does support native ES modules but it relies on Webpack to bundle and serve these modules during development, instead of serving them directly in their native form as Vite does.&lt;br&gt;
 &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;RollUp as it's Bundler:&lt;/strong&gt;&lt;br&gt;
RollUp is a bundler known for its exceptional function in producing a smaller and highly optimized bundler. RollUp also has tree-shaking features—a technique used in module bundlers to remove unused code, reducing the final bundle size. Vite relies on RollUp for its production builds as it create smaller bundles.&lt;br&gt;
&lt;strong&gt;CRA&lt;/strong&gt; uses the Webpack as its bundler, which also supports tree-shaking but can create larger bundles and may not be as efficient as RollUp.&lt;br&gt;
 &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Support Multiple Frameworks:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Vite&lt;/strong&gt; supports multiple frameworks such as Svelte, Vue, Preact, etc, which makes it a multipurpose tool.&lt;br&gt;
&lt;strong&gt;CRA&lt;/strong&gt; is React-specific.&lt;br&gt;
 &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Built-in EsBuild tool:&lt;/strong&gt;&lt;br&gt;
Esbuild is an ultra-fast JavaScript bundler that hastens the building process in modern web development.&lt;br&gt;
&lt;strong&gt;Vite&lt;/strong&gt; uses the EsBuild tool for its development server and HMR and relies on RollUp for its production build.&lt;br&gt;
 &lt;strong&gt;CRA&lt;/strong&gt;, by contrast, does not. Instead, it relies entirely on Webpack for bundling and development process.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Supports JavaScript and Typescript:&lt;/strong&gt;&lt;br&gt;
Vite has built-in support for modern JavaScript (JS), Typescript (TS), and additional features like CSS, JSX, and more plugins without requiring additional configuration.&lt;br&gt;
&lt;strong&gt;CRA&lt;/strong&gt; may require additional configuration to completely support some features.&lt;br&gt;
 &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;PlugIn API: &lt;/strong&gt;&lt;br&gt;
One of the features that makes vite exceptional is the &lt;strong&gt;plugin API&lt;/strong&gt;. Developers can customize &lt;strong&gt;Vite's&lt;/strong&gt; functionality using the &lt;strong&gt;plugin API&lt;/strong&gt;. &lt;br&gt;
Additionally, the plugin API is compatible with the RollUp PlugIn. &lt;br&gt;
There isn't a plugin API included with &lt;strong&gt;Create-React-App (CRA)&lt;/strong&gt;. The &lt;strong&gt;CRA&lt;/strong&gt; offers a zero-configuration setup; although it permits some customization using environment variables, plugins are not supported natively.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Key Differences
&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%2F11u9am03pj3ducugabrh.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%2F11u9am03pj3ducugabrh.png" alt="Image description" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step-by-step guide using NPM
&lt;/h2&gt;

&lt;p&gt;1.Open the terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
npm create vite@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Input the project name&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;It would display a list of frameworks. Select your preferred framework. In this case, its React
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;/div&gt;



&lt;p&gt;4.Select JavaScript only from the list of languages provided if you'll be using JavaScript&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;5.Install the npm&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;6.Run the code on the server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;`&lt;br&gt;
 Yay! You're good to go.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tip
&lt;/h2&gt;

&lt;p&gt;Vite's &lt;code&gt;index.html&lt;/code&gt; file is located in the root directory, unlike in CRA, where the file is in the &lt;code&gt;public&lt;/code&gt; folder. Avoid moving it, as this can disrupt the project's setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;In conclusion, Vite is a tool well-suited for either small or large real-world applications, while CRA could be considered when building smaller applications.  If you haven't tried Vite yet,  ensure you give it a shot.&lt;br&gt;
This article has covered the modern built-in features of Vite, its differences from CRA, and the steps for setting up Vite.&lt;br&gt;
I hope you found this article useful. Feel free to drop your suggestions in the comment box.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://vite.dev/guide/why.html#why-not-bundle-with-esbuild" rel="noopener noreferrer"&gt;Why Vite&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;Vite- Server Side Rendering(SSR)&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.theseus.fi/handle/10024/860241" rel="noopener noreferrer"&gt;Study Site&lt;/a&gt;&lt;br&gt;
 &lt;a href="https://www.dhiwise.com/post/es-modules-for-browser-react-features-future" rel="noopener noreferrer"&gt;ES Modules&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.theseus.fi/handle/10024/860241" rel="noopener noreferrer"&gt;Study Citation&lt;/a&gt;&lt;br&gt;
Check out stack overflow for common errors that can arise when using Vite.&lt;/p&gt;

&lt;h2&gt;
  
  
  Glossary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Modules&lt;/strong&gt;: small pieces of code, each managing a specific functionality in an application&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hot Module Replacement(HMR)&lt;/strong&gt;: HMR is a development feature that allows update to module to be introduced into a running application without a full reload of the browser. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Native ES Modules:&lt;/strong&gt; are a standardized way to organize JavaScript code, introduced in ES6. They use &lt;code&gt;import&lt;/code&gt; and &lt;code&gt;export&lt;/code&gt; statements to manage dependencies, allowing for better code organization and tree shaking.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tree Shaking:&lt;/strong&gt; is an optimization technique used in module bundlers to eliminate unused code, reducing the final bundle size and improving performance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>vite</category>
    </item>
    <item>
      <title>Creating Scroll Animations Using ScrollReveal</title>
      <dc:creator>Muslimat Mojeed </dc:creator>
      <pubDate>Sun, 28 Apr 2024 15:32:01 +0000</pubDate>
      <link>https://dev.to/symplymuslimah12/creating-scroll-animations-using-scrollreveal-43jp</link>
      <guid>https://dev.to/symplymuslimah12/creating-scroll-animations-using-scrollreveal-43jp</guid>
      <description>&lt;p&gt;As developers, we strive to create websites or applications that does not only deliver information but also engages and pleases users. One of the powerful ways in which this can be achieved is through the use of &lt;strong&gt;animation&lt;/strong&gt;.&lt;br&gt;
&lt;strong&gt;Animation&lt;/strong&gt; in web development refers to the movement or transition of elements on a webpage, typically in response to user interactions (such as scrolling, clicking, or hovering) or as part of a visual effect to enhance the user experience.&lt;br&gt;
&lt;strong&gt;Animations&lt;/strong&gt; can change the static state of a website, convey information more effectively making interactions more intuitive and enjoyable for users and as well enhance the overall user experience.&lt;br&gt;
In this article, we'll explore how you can effectively use the &lt;strong&gt;scrollReveal.js library&lt;/strong&gt; to add scroll animations to web applications.&lt;br&gt;
If you're an experienced JavaScript developer looking to spice up your projects, this article will provide the knowledge needed to create a beautiful scroll animations that will impress users and elevate your web pages. &lt;/p&gt;
&lt;h2&gt;
  
  
  Understanding ScrollReveal.js library
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;ScrollReveal.js&lt;/strong&gt; is a JavaScript library that allows you to easily add scroll animations to elements on a web page. &lt;br&gt;
With &lt;strong&gt;scrollReveal.js&lt;/strong&gt;, you can define various animation properties such as duration, delay, easing, direction and more to create visually appealing effects.&lt;br&gt;
One of the key features of &lt;strong&gt;scrollReveal.js&lt;/strong&gt; is its ease of use. You can quickly set up animations with just few lines of code, making it accessible to both beginners and experienced developers.&lt;br&gt;
Additionally, &lt;strong&gt;ScrollReveal.js&lt;/strong&gt; is lightweight and efficient, ensuring that your animations run smoothly without impacting the overall performance of your website.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;To install &lt;strong&gt;ScrollReveal.js&lt;/strong&gt;, you can try out the following ways:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;scrollreveal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add scrollreveal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also include the ScrollReveal.js directly in your &lt;code&gt;HTML&lt;/code&gt; file using a &lt;strong&gt;CDN&lt;/strong&gt;(Recommended for JavaScript project):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/scrollreveal"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Customization
&lt;/h2&gt;

&lt;p&gt;You can customize each element's animation by selecting it with a unique class and specifying its animation properties in the reveal method. Some common customization options include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Duration&lt;/strong&gt;: the duration of the animation is in milliseconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Origin&lt;/strong&gt;: the starting point of the animation. It may be top, 
bottom, left, right.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Distance&lt;/strong&gt;: the distance the element has to move during animation can be modified.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delay&lt;/strong&gt;: the time it takes before the animation starts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easing&lt;/strong&gt;: it can be linear, ease-in, ease-out etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reset&lt;/strong&gt;: whether the animation should be reset when the element is not in view or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"heading"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Hi header!!!
&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nc"&gt;ScrollReveal&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;reveal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.heading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,{&lt;/span&gt;&lt;span class="na"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;top&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;distance&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;20px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is important to note that if you'll be using the same animation properties for multiple elements on your web page , you can declare the properties at the beginning of the code . This prevents the repetition and makes your code more efficient. &lt;br&gt;
&lt;strong&gt;Reference Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"welcome"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Welcome
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"contact"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Contact Me
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nc"&gt;ScrollReveal&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;distance&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;120px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nc"&gt;ScrollReveal&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;reveal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.welcome,.contact&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,{&lt;/span&gt;&lt;span class="na"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;left&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="na"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices for using ScrollReveal.js
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use it Sparingly&lt;/strong&gt;: Avoid overusing scroll animations, as they can distract users from your content if used excessively.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Customization:&lt;/strong&gt; Customize animations to match the website's design and branding.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Accessibility&lt;/strong&gt;: Ensure that the web page is accessible and usable even without animations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Testing and Feedback&lt;/strong&gt;: Test animations on different devices and screen sizes to ensure they work as expected. Solicit feedback from users to gauge the effectiveness of your animations in enhancing the user experience.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Common Errors and Issues with ScrollReveal.js:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Elements Not Revealing&lt;/strong&gt;: Check if the elements that wants to be animated has been correctly selected. Ensure that the &lt;strong&gt;ScrollReveal&lt;/strong&gt; instance is properly initialized and that the library is loaded before your script runs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Animation Not Working as Expected&lt;/strong&gt;: Double-check animation properties and syntax to ensure they are correctly set. Verify that there are no conflicting styles or JavaScript that might be interfering with the animations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance Problems&lt;/strong&gt;: If you experience performance issues, consider reducing the number of animated elements or simplifying the animations. Optimize your animations for performance by  avoiding complex animations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compatibility Issues:&lt;/strong&gt; Check the compatibility of &lt;strong&gt;ScrollReveal.js&lt;/strong&gt; with the browsers and devices you are targeting. Consider using polyfills or alternative solutions for browsers that do not support the features used by ScrollReveal.js.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Debugging&lt;/strong&gt;: Use browser developer tools to debug any issues with ScrollReveal.js implementation. Inspect the console for errors and log messages to help identify and fix problems.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By following these best practices and being aware of common errors, ScrollReveal.js can be used effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;In a nutshell, &lt;strong&gt;ScrollReveal.js&lt;/strong&gt; is a powerful tool for adding scroll animations to elements on the web page. So, the next time you start a new project or refactor an existing one, try to explore the library and see the difference it can make in your project.&lt;br&gt;
This article has explored the use of ScrollReveal.js for scroll animations.&lt;br&gt;
I hope you gained from this article. Be free to drop your suggestions or questions in the comment box.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;p&gt;Explore the ScrollReveal.js Library to learn more about their documentations &lt;a href="https://scrollrevealjs.org/" rel="noopener noreferrer"&gt;ScrollReveal library&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding 'Use strict' in JavaScript</title>
      <dc:creator>Muslimat Mojeed </dc:creator>
      <pubDate>Tue, 16 Apr 2024 21:54:23 +0000</pubDate>
      <link>https://dev.to/symplymuslimah12/understanding-use-strict-in-javascript-4ik3</link>
      <guid>https://dev.to/symplymuslimah12/understanding-use-strict-in-javascript-4ik3</guid>
      <description>&lt;h2&gt;
  
  
  Introduction to strict mode in JavaScript
&lt;/h2&gt;

&lt;p&gt;Having written some lines of JavaScript code, you are probably familiar with the quirks and challenges of the language. Perhaps you've encountered those undeclared variables that cause silent errors in your code, leaving you puzzled about their origins. &lt;br&gt;
In the dynamic realm of JavaScript, where creativity meets complexity, developers often encounter subtle bugs and unexpected behaviors. To address these challenges, &lt;code&gt;ECMAScript 5 (ES5)&lt;/code&gt; introduced a feature known as &lt;strong&gt;'use strict'&lt;/strong&gt;. The &lt;strong&gt;'use strict'&lt;/strong&gt; perform additional checks and apply stricter rules to code, helping to catch programming errors and potentially improving performance. It was a significant update to the language and has been widely adopted by developers due to its benefits in catching errors and improving code quality.&lt;br&gt;
Whether you're just starting out or have some experience in JavaScript, this article will explore the fundamentals of strict mode in JavaScript. The significance and why every developer should know how to use it effectively will also be discussed.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Strict Mode?
&lt;/h2&gt;

&lt;p&gt;Strict mode is a special mode in JavaScript that allows developers to opt into a set of rules and restrictions that are not enforced by default.&lt;br&gt;
Strict mode in JavaScript is like having a helpful friend who keeps an eye out for mistakes while you're coding. It's a special set of rules that make JavaScript more careful about how it reads and runs your code. &lt;br&gt;
It helps catch errors that would otherwise go unnoticed, such as using variables without declaring them first or defining functions with duplicate parameter names. By enabling strict mode, developers can write code that is safer, easier to maintain, and more compatible with future versions of JavaScript.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Use Strict Mode in JavaScript
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It assists in writing safer and more readable code.&lt;/li&gt;
&lt;li&gt;Strict Mode helps catch common programming errors which can lead to a more predictable and reliable code.&lt;/li&gt;
&lt;li&gt;Strict mode helps developers write code that is more compatible with future versions of JavaScript, as it encourages the use of modern language features and best practices.&lt;/li&gt;
&lt;li&gt;Strict mode prohibits some syntax that could be misleading or problematic.&lt;/li&gt;
&lt;li&gt;Due to modifications that facilitate JavaScript engines' optimisations, code in strict mode occasionally runs quicker than identical code that isn't in strict mode.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Enabling Strict Mode in JavaScript
&lt;/h2&gt;

&lt;p&gt;To enable strict mode in JavaScript, simply add the following line of code to the beginning of your script or function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This statement tells the JavaScript engine to enter strict mode for the current script or function, enabling the stricter rules and checks provided by strict mode.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common errors and issues addressed by strict mode
&lt;/h2&gt;

&lt;p&gt;The following are examples of some of the errors caught by strict mode:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Undeclared variables:&lt;/strong&gt; In strict mode, trying to assign a value to a variable that has not been declared with &lt;code&gt;var&lt;/code&gt;, &lt;code&gt;let&lt;/code&gt;, or &lt;code&gt;const&lt;/code&gt; will throw a &lt;code&gt;ReferenceError&lt;/code&gt;. This helps catch potential issues with typos or variables that were intended to be declared but were missed.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ReferenceError: x is not defined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Function parameter name restrictions:&lt;/strong&gt; In strict mode, defining a function with duplicate parameter names (e.g., &lt;code&gt;function func(a, a)&lt;/code&gt;) will throw a &lt;code&gt;SyntaxError&lt;/code&gt;. This helps enforce unique parameter names, which can prevent confusion and bugs.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// SyntaxError: Duplicate parameter name not allowed in this context&lt;/span&gt;
       &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Duplicate property names:&lt;/strong&gt; In strict mode, defining multiple properties with the same name in an object literal or function parameter list will throw a &lt;code&gt;SyntaxError&lt;/code&gt;. This helps prevent accidental duplication of property names, which can lead to unexpected behavior.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="na"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="na"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="c1"&gt;// SyntaxError: Duplicate data property in object literal not allowed in strict mode&lt;/span&gt;
   &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Using &lt;code&gt;eval&lt;/code&gt; in a local scope:&lt;/strong&gt; When you use eval in a specific part of your code (like inside a function) and you're in strict mode, it creates a sort of "bubble" where any new variables you create inside that eval don't affect the rest of your code. This can be confusing because changes you make inside eval don't carry over to the main part of your code.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;evalInLocalScope&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="nf"&gt;eval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;var x = 20;&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Returns 10 because eval creates its own scope in strict mode&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Octal syntax:&lt;/strong&gt; In strict mode, octal literals (numbers with a leading zero, e.g., &lt;code&gt;012&lt;/code&gt;) are not allowed and will throw a &lt;code&gt;SyntaxError&lt;/code&gt;. This helps prevent
potential confusion with decimal numbers and improves code clarity.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;012&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;//SyntaxError.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Delete of an undeletable property:&lt;/strong&gt; Trying to delete a property that is not deletable (such as properties of built-in objects like &lt;code&gt;Object.prototype&lt;/code&gt;
) will throw a &lt;code&gt;TypeError&lt;/code&gt; in strict mode. This prevents unintended deletion of critical properties.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// TypeError: Cannot delete property 'prototype' of function Object() { [native code] }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These examples illustrate some of the ways strict mode in JavaScript helps catch common errors and enforce stricter rules, ultimately leading to more reliable and maintainable code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best practices for using strict mode in JavaScript
&lt;/h2&gt;

&lt;p&gt;Just like any other tool, it's important to use strict mode judiciously and understand its implications. In this section, we'll discuss best practices for using strict mode effectively:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to Use Strict Mode&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use Strict Mode Globally&lt;/strong&gt;: It's a good practice to enable strict mode at the beginning of your scripts or modules to ensure that the entire codebase benefits from its advantages. This can be done by adding &lt;strong&gt;'use strict';&lt;/strong&gt; at the beginning of your JavaScript file or function.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//  strict mode syntax at the beginning of the script &lt;/span&gt;
&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myScript&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Yo! I just got activated!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use Strict Mode in Functions&lt;/strong&gt;: If you prefer to use strict mode only in specific functions, you can enable it at the beginning of those functions. This allows you to apply strict mode selectively, where it's most beneficial.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;myFunctionScript&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Function strict mode &lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use strict&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;mySF&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Yo, I just got activated!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use Strict Mode in Modules&lt;/strong&gt;: When working with JavaScript modules (ES6 modules), enabling strict mode at the beginning of each module is a recommended practice. This helps maintain a consistent and predictable coding environment within each module.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Potential pitfalls to avoid&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While strict mode offers many benefits, there are some potential pitfalls to be aware of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compatibility issues:&lt;/strong&gt; Not all browsers support strict mode, so using it may cause compatibility problems with older browsers. It's important to test your code in different environments to ensure compatibility.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;'use strict' is contagious:&lt;/strong&gt; Once you enable strict mode in a script, all code within that script, as well as any other scripts included on the page, will run in strict mode. This can be problematic if other scripts are not intended to run in strict mode.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;All or nothing:&lt;/strong&gt; Once you enable it, it applies to all code within that scope. This means that if you only want to use strict mode for certain parts of your code, you'll need to separate those parts into different scripts or functions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance impact:&lt;/strong&gt; While enabling strict mode itself does not significantly impact performance, the additional error checking and restrictions imposed by strict mode can sometimes lead to slightly slower code execution. However, the benefits of catching errors early and writing more maintainable code often outweigh this minor performance impact.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's important to weigh the benefits of strict mode against these potential pitfalls and use it judiciously in your projects. By understanding these details, you can leverage strict mode effectively to improve the quality and reliability of your JavaScript code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;Conclusively, strict mode is a valuable tool that should be embraced by JavaScript developers. By enabling strict mode in your projects, you can write code that is more robust, reliable, and future-proof. So, the next time you start a new project or refactor an existing one, add &lt;strong&gt;'use strict'&lt;/strong&gt;; to the beginning of your scripts or functions and experience the benefits for yourself. It's a small step that can lead to significant improvements in your codebase.&lt;br&gt;
This article has explored the fundamentals of using strict mode, it's significance and why it is essential for every JavaScript developer.&lt;/p&gt;

&lt;p&gt;I hope a lot was gained from this article. Be free to drop your suggestions or questions in the comment box.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;p&gt;Explore these resources to deepen your understanding of strict mode.&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode" rel="noopener noreferrer"&gt;MDN Web Docs on strict mode&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Using Git and GitHub for collaboration</title>
      <dc:creator>Muslimat Mojeed </dc:creator>
      <pubDate>Sun, 07 Apr 2024 21:55:47 +0000</pubDate>
      <link>https://dev.to/symplymuslimah12/using-git-and-github-for-collaboration-1dmo</link>
      <guid>https://dev.to/symplymuslimah12/using-git-and-github-for-collaboration-1dmo</guid>
      <description>&lt;h2&gt;
  
  
  Overview of Git collaboration
&lt;/h2&gt;

&lt;p&gt;Watching tutorials on Git and applying the knowledge to personal projects can be interesting, but collaborating using Git could present another challenge that one may face when the need arises.&lt;/p&gt;

&lt;p&gt;As we continue to explore the field of software development, teamwork is essential to creating reliable and creative solutions. As projects get more complicated and involve more people, efficient teamwork becomes essential to maintainability and smooth development.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This article aims to extensively explain the guidelines of using Git for collaboration. It will delve into setting up a hosting platform like GitHub for collaboration, various branching strategies, collaborative Git workflows, different methods of cloning, as well as troubleshooting and resolving conflict techniques in Git collaboration.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;It's important to note that knowledge of version control system(Git) and GitHub is required before reading this article, as this article mainly focuses on guidelines of using Git for collaboration.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps for setting up GitHub for collaboration
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Creating a collaborative Git repository:&lt;/strong&gt;
Creating a collaborative Git repository (remote repository) is the foundational step towards effective teamwork. Whether your team is small or large, setting up the repository correctly ensures a smooth collaborative workflow. Quick guide on how to create a git repository:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Choose a hosting platform:&lt;/strong&gt; Choose a hosting platform for your Git repository first. Popular options include Bitbucket, GitHub, GitLab, and so on. Because every platform has different features, take your team's demands and preferences into account. In the case of this article, we will be using &lt;strong&gt;GitHub&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Create a new repository&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Initialize a README file:&lt;/strong&gt; Add a README file to your repository for project documentation. This provides summary of goals and set-up instructions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Invite collaborators:&lt;/strong&gt; After creating the repository, add collaborators that will be contributing to the project to a repository.&lt;br&gt;
To do this, navigate to settings, select collaborators, click on &lt;strong&gt;'Add people'&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Fbz62gcc1hik74qwy8eg3.jpg" 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%2Fbz62gcc1hik74qwy8eg3.jpg" alt="invite collaborators" width="720" height="812"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;strong&gt;Configure repository settings:&lt;/strong&gt; Repository changes can be made in the settings. Hosting platforms like GitHub enables you to choose who can see, clone, and contribute to the repository as well as set up access controls.
It also enables branch protection rule to prevent unintentional pushes towards vital branches&lt;/li&gt;
&lt;/ul&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%2Fnsghwpyf4vvh3nwgqil7.jpg" 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%2Fnsghwpyf4vvh3nwgqil7.jpg" alt="branch protection rule" width="720" height="1483"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;Establish Branching strategies:&lt;/strong&gt;&lt;br&gt;
Branching strategies in Git collaboration refer to the practices and conventions used to manage code changes and collaboration among team members within a Git repository. These strategies define how branches are created, named, and merged to facilitate efficient development, testing, and deployment workflows. Here are some of the ways to establish branching:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Main based Branching:&lt;/strong&gt; All developers work are done directly on the main branch. Developers make changes directly on the main branch.
The main branching strategy simplifies the process of making changes, but it has disadvantages such as lack of isolation, limited review and testing of codes, difficulty in reverting some changes and increases the risk of unintended impacts on the codebase.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Ensure you're on the main branch
git checkout main

# Make changes to the code directly on the main branch
# Add, commit, and push changes
git add .
git commit -m "Fix bug"
git push origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Feature branching:&lt;/strong&gt; Each new feature is developed in a separate branch.
Developers create feature branches off the main branch, work on their changes, and merge them back when ready.
This provides isolation for development, allowing multiple features to progress simultaneously without interfering with each other.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Create a new branch for a feature
git checkout -b feature/new-feature

# Make changes to the code
# Add, commit, and push changes to the feature branch
git add .
git commit -m "Implement new feature"
git push --set-upstream origin &amp;lt;branch-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Collaborative Git workflow
&lt;/h2&gt;

&lt;p&gt;The collaborative Git workflow is a methodology for multiple developers to work together on a project using git as the version control system.&lt;/p&gt;

&lt;p&gt;When it comes to Git collaboration, developers work together via a shared repository that is frequently housed on websites like Bitbucket, GitHub, and GitLab. A central hub where team members can push and pull changes is this repository. For various activities, like adding a feature or repairing a bug, developers make branches, which they later merge back into the main source.&lt;/p&gt;

&lt;p&gt;Consider a scenario of three talented developers—&lt;strong&gt;Alice, Bob and Dave&lt;/strong&gt;—were tasked with building a new web application for their client. Alice, with her strong leadership skills, volunteered to take on the role of team lead for the project. The following are the ways Alice and her teammates worked on building the project:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Alice sets up the repository, initialize a README file and invited her teammates as collaborators.&lt;/li&gt;
&lt;li&gt;She designated the main branch as the primary development branch, setting the stage for collaborative work.&lt;/li&gt;
&lt;li&gt;Bob and Dave each cloned the repository to their local machines and created feature branches for their respective tasks.
Bob and clone can clone in three ways. It's either they clone using &lt;strong&gt;&lt;em&gt;HTTPS,SSH Keys or Command Line Interface&lt;/em&gt;&lt;/strong&gt;
&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 git@github.com:username/repository.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Bob and Dave decided to clone with SSH for efficiency and security reasons. The use of &lt;strong&gt;SSH, HTTPS or CLI&lt;/strong&gt; for cloning will be discussed subsequently.&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%2Fzqpe3j80mtnrt0fs9f96.jpeg" 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%2Fzqpe3j80mtnrt0fs9f96.jpeg" alt="Image description" width="720" height="647"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;&lt;strong&gt;You need to note that as a collaborator, you don't fork a repository. Forking creates a copy of the repository in a new repository on your GitHub page. However, in the case of collaboration, you want to collaborate directly on the same GitHub repository with your teammates.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;4.Over the following days, the team members worked diligently on their assigned tasks within their feature branches.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Make changes to the code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5.They made frequent commits, pushing their changes to the remote repository to keep their codebase up to date.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Add, commit, and push changes to the feature branch
git add .

git commit -m "commit changes"

git push --set-upstream origin &amp;lt;branch-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6.Once they completed their tasks, they pushed their changes. Bob and Dave created pull requests from their feature branches to the main branch on GitHub. On the GitHub page, they noticed a button labeled &lt;strong&gt;"Compare and pull request"&lt;/strong&gt; after clicking on the pull request option. Bob and Dave clicked on this option to push the changes from their local repositories to the remote repository.&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%2Fcocxezpeld84rtqntibg.jpeg" 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%2Fcocxezpeld84rtqntibg.jpeg" alt=".." width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;7.This took them to the &lt;strong&gt;“Open a pull request"&lt;/strong&gt; page. From here, a brief description of what each of them changed was written. Each of them clicked on the &lt;strong&gt;“Reviewers”&lt;/strong&gt; tab and Alice being the team lead was selected as the &lt;strong&gt;“Merge Master that is she will be in charge of merging the branches”&lt;/strong&gt;. After that, they clicked on &lt;em&gt;"“Create pull request”&lt;/em&gt;* from their ends.&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%2F062kng37txe0ec1ifyom.jpeg" 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%2F062kng37txe0ec1ifyom.jpeg" alt="..." width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;8.When Alice logged into her GitHub account, she received notifications informing her that she had been assigned as a reviewer. A yellow bar appeared at the top of the pull request button, indicating that one of her teammates had "requested her review on this pull request." Alice, acting as the team lead, clicked on the &lt;strong&gt;"Add your review"&lt;/strong&gt; button reviewed each pull request carefully, providing feedback and suggestions for improvement.&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%2F5nfgo0rj5kauomwiyzml.jpeg" 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%2F5nfgo0rj5kauomwiyzml.jpeg" alt="Image description" width="720" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;9.After thorough review and approval from Alice, She scrolled to the bottom of the pull requests and she clicked on the &lt;strong&gt;"Merge pull request"&lt;/strong&gt;. The branches was finally merged into the main branch.&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%2Fz56xq91vkr0cacotjuzr.jpeg" 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%2Fz56xq91vkr0cacotjuzr.jpeg" alt="Image description" width="800" height="478"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;10.Alice sees a &lt;strong&gt;“Pull request successfully merged and closed”&lt;/strong&gt; message. She clicked on the button “Delete branch" to delete the feature branches.&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%2F7kg5h07l737t1im7nk2p.jpeg" 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%2F7kg5h07l737t1im7nk2p.jpeg" alt="Image description" width="800" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Note: Deleting a branch is optional.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To learn a bit more about using Git for collaboration, check out this tutorial video below:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://youtu.be/MnUd31TvBoU?si=3aiFLAyOaNwlDoZM" rel="noopener noreferrer"&gt;Git for collaboration&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Ways of cloning
&lt;/h2&gt;

&lt;p&gt;Repositories can be cloned using HTTPS, SSH or the Command Line Interface(CLI).&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%2Fc2255k5cecde61dkdlgf.jpeg" 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%2Fc2255k5cecde61dkdlgf.jpeg" alt="Image description" width="720" height="647"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;Cloning with HTTPS:&lt;/strong&gt; When you clone a repository using HTTPS, you're getting its contents through a secure connection. You use your username, password, or a personal access token to prove you have the right to access the repository. This method is widely supported and easy to use, so most people find it convenient.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/username/repository.git
# Replace `username/repository` with the GitHub username and repository name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.&lt;strong&gt;Cloning a repository using SSH:&lt;/strong&gt; It involves using the &lt;strong&gt;Secure Shell (SSH) protocol&lt;/strong&gt; for authentication and communication. When you clone a repository using &lt;strong&gt;SSH&lt;/strong&gt;, you authenticate with the GitHub using an SSH key pair: &lt;strong&gt;a public key&lt;/strong&gt; stored on the platform and &lt;strong&gt;a private key&lt;/strong&gt; stored on your local system. SSH cloning is secure and efficient, especially for users who prefer no-password authentication and have configured SSH keys for Git operations. Let's walk through the process step by step:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generating SSH Keys:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Open Terminal (Command Prompt on Windows):&lt;/strong&gt; This is where you'll run the commands to generate your SSH keys.
Run the &lt;code&gt;ssh-keygen&lt;/code&gt;command in the terminal
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Replace `"your_email@example.com"` with your actual email address.
# This command generates a new SSH key pair using the RSA algorithm with a 4096-bit key size.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Choose a Location and Passphrase (Optional):&lt;/strong&gt; After running the command, you'll be prompted to choose a location to save the SSH keys. Press Enter to accept the default location (&lt;code&gt;~/.ssh/id_rsa&lt;/code&gt;) or specify a different location if desired.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Passphrase:&lt;/strong&gt; A passphrase is a sequence of words, characters, or symbols used to encrypt and protect sensitive information, such as private keys or encrypted files. It acts as an additional layer of security beyond just having the private key or encrypted data itself. When setting up certain security mechanisms, like SSH keys, users have the option to add a passphrase to enhance security. You can also choose to set a passphrase for added security. This is optional but recommended.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;View and Copy the Public Key:&lt;/strong&gt; Once the keys are generated, you'll see a message indicating where the keys were saved. To view your public key, use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat ~/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will display your public key in the terminal. You'll need to copy this key to your clipboard and add the key to your GitHub as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding SSH Key to GitHub:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Log in to git hub.&lt;/li&gt;
&lt;li&gt;Navigate to the repository on GitHub and click on the &lt;strong&gt;"code"&lt;/strong&gt; button labelled.&lt;/li&gt;
&lt;li&gt;Add SSH Key: Click on the &lt;strong&gt;"add a new public key"&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;Give your SSH key a descriptive title and paste your public key into the &lt;strong&gt;"Key"&lt;/strong&gt; field.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;"Add SSH key"&lt;/strong&gt; button to save your key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using SSH Keys for Git:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Clone Repositories:&lt;/strong&gt;&lt;br&gt;
Clone the repository by copying the SSH URL after adding the SSH key. In the terminal, navigate to the directory where you want to clone the repository and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone git@github.com:username/repository.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the repository is cloned, you can perform Git operations as usual, such as making commits, pushing changes, and pulling updates.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;Note that each team member generate their own SSH key pair in which this allows them to authenticate individually and securely access the Git repositories hosted on GitHub. While each team member has their own separate SSH key pair for authentication, they can still collaborate and work together on the same repositories.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;CLI cloning:&lt;/strong&gt; Cloning a repository through the command-line interface (CLI) involves using a terminal or command prompt to run Git commands. Regardless of whether you choose HTTPS or SSH cloning, the process is initiated and managed using Git commands in the CLI. This allows you to clone repositories, manage branches, make commits, and perform other Git operations directly from the terminal, providing flexibility and control over your development workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting and resolving conflict
&lt;/h2&gt;

&lt;p&gt;Troubleshooting and resolving conflicts is an essential aspect of collaborative development. It is essential to adhere to certain procedures while troubleshooting and resolving issues in Git collaboration in order to guarantee a seamless resolution process. Here's a guide on how to effectively address conflicts that may arise during the development process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Identify the merging conflict:&lt;/strong&gt;  Merge conflicts arise when Git is unable to automatically reconcile code discrepancies between two commits, usually as a result of numerous developers making simultaneous changes to the same lines in a file. Reviewing code changes, discussing discrepancies, and understanding the root cause of the conflict is the initial step in resolving merge conflict.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.&lt;strong&gt;Resolving merge conflict:&lt;/strong&gt; Opening the disputed file, making the required modifications, staging the new content with git add, and generating a new commit with git commit are the procedures involved in resolving merge conflicts.&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;Collaborative Conflict Resolution:&lt;/strong&gt; Working in separate isolated branches to prevent conflicts and the use of the Git merge command to merge feature branches together and resolve conflicting changes.&lt;/p&gt;

&lt;p&gt;4.&lt;strong&gt;Collaborate on solutions:&lt;/strong&gt;&lt;br&gt;
Collaborate to come up with a few possible solutions to the conflict. Promote original thought and investigate other strategies that successfully deal with the fundamental problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Best Ways to Prevent Conflicts&lt;/strong&gt; &lt;br&gt;
To reduce conflicts, team members must communicate about the portions of the files they are working on, pull changes before committing or pushing, and use the appropriate Git commands and tools.&lt;/p&gt;

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

&lt;p&gt;This article has explored the guidelines of using Git for collaboration, challenges of using Git in a collaborative context and offers advice on common issues and industry best practice for effective teamwork in software development.&lt;/p&gt;

&lt;p&gt;I hope a lot was gained from this article. Be free to drop your suggestions or questions in the comment box.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Reading
&lt;/h2&gt;

&lt;p&gt;If the article was insightful, you can research and explore these topics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Git best practices for team collaboration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extensive study on Branching strategies etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>github</category>
      <category>git</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
