<?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>Forem: Dev Raj Sharma</title>
    <description>The latest articles on Forem by Dev Raj Sharma (@codewithsharma).</description>
    <link>https://forem.com/codewithsharma</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%2F1250599%2F7f846ce5-166d-4153-ad9a-92f12c782ebf.png</url>
      <title>Forem: Dev Raj Sharma</title>
      <link>https://forem.com/codewithsharma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/codewithsharma"/>
    <language>en</language>
    <item>
      <title>Chrome vs Brave: A Developer's Perspective</title>
      <dc:creator>Dev Raj Sharma</dc:creator>
      <pubDate>Fri, 12 Jan 2024 06:59:01 +0000</pubDate>
      <link>https://forem.com/codewithsharma/chrome-vs-brave-a-developers-perspective-26dc</link>
      <guid>https://forem.com/codewithsharma/chrome-vs-brave-a-developers-perspective-26dc</guid>
      <description>&lt;p&gt;As developers, choosing the right browser is a crucial decision that impacts our workflow and productivity. Two browsers that often find themselves in the spotlight are Google Chrome and Brave. In this post, let's dive into a comparison between these two, exploring their features and how they cater to the needs of developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Performance:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Chrome:&lt;/strong&gt;&lt;br&gt;
Known for its speed, Chrome is a performance powerhouse. It excels in rendering web pages quickly and efficiently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Brave:&lt;/strong&gt;&lt;br&gt;
Brave, built on Chromium, inherits some of Chrome's performance benefits. It offers a fast browsing experience, with a focus on blocking ads and trackers to enhance speed.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Privacy and Security:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Chrome:&lt;/strong&gt;&lt;br&gt;
While Chrome has made strides in privacy features, it's associated with Google, which raises concerns for some users. It may collect data for personalized ads and services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Brave:&lt;/strong&gt;&lt;br&gt;
Brave puts a strong emphasis on privacy. It blocks ads and trackers by default and offers features like Tor browsing for enhanced anonymity.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Customizability:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Chrome:&lt;/strong&gt;&lt;br&gt;
Chrome has a vast selection of extensions and themes, allowing users to tailor their browsing experience extensively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Brave:&lt;/strong&gt;&lt;br&gt;
Brave supports Chrome extensions, making it customizable. However, its primary focus on privacy might limit some extension choices.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Built-in Features:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Chrome:&lt;/strong&gt;&lt;br&gt;
Chrome comes with a variety of built-in tools for developers, including the Developer Tools, which are comprehensive and powerful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Brave:&lt;/strong&gt;&lt;br&gt;
Brave inherits the developer tools from Chromium, ensuring compatibility with Chrome extensions. However, it may lack some of the latest features found in Chrome.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Rewards and Ad Blocking:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Chrome:&lt;/strong&gt;&lt;br&gt;
Chrome doesn't have built-in ad-blocking, and users might need extensions for a similar experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Brave:&lt;/strong&gt;&lt;br&gt;
Brave takes a different approach, blocking ads by default and rewarding users with Basic Attention Tokens (BAT) for viewing privacy-respecting ads.&lt;/p&gt;

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

&lt;blockquote&gt;
&lt;p&gt;The choice between Chrome and Brave ultimately depends on individual preferences and priorities. If speed and a wide array of extensions are crucial, Chrome might be the preferred choice. On the other hand, if privacy and ad-blocking are top priorities, Brave stands out.&lt;br&gt;
 Both browsers have their merits, and the best choice may vary based on your specific needs as a developer. It's worth trying both to see which aligns better with your workflow and values.&amp;gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;What's your preferred browser, and why? Share your thoughts in the comments below!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>developer</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Introducing Project IDX: Revolutionizing Development on the Cloud</title>
      <dc:creator>Dev Raj Sharma</dc:creator>
      <pubDate>Wed, 10 Jan 2024 14:26:21 +0000</pubDate>
      <link>https://forem.com/codewithsharma/introducing-project-idx-revolutionizing-development-on-the-cloud-kh7</link>
      <guid>https://forem.com/codewithsharma/introducing-project-idx-revolutionizing-development-on-the-cloud-kh7</guid>
      <description>&lt;p&gt;Developers, brace yourselves for a groundbreaking shift in the development landscape with Project IDX. This experimental, web-based integrated development environment (IDE) is set to transform the way we build and deploy applications. Whether you're a seasoned developer or just starting your coding journey, IDX is here to simplify your development workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Project IDX?
&lt;/h2&gt;

&lt;p&gt;Project IDX is not just an IDE; it's a vision for a future where setting up development environments becomes a hassle-free experience. Built on the popular Code OSS project and leveraging the robust infrastructure of Google Cloud, IDX offers fully configurable virtual machines (VMs) to ensure reliability, safety, and complete configurability - all within your browser.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Key Features to Propel Your Development Journey
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Familiar Environment&lt;/strong&gt;&lt;br&gt;
IDX provides a familiar environment by being built on the widely used Code OSS project. This familiarity extends to developers who can seamlessly transition into IDX without the steep learning curve.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. IDX AI - Your Coding Companion&lt;/strong&gt;&lt;br&gt;
IDX introduces AI into the development process with its AI-powered code suggestions and chat features. Need help generating new code, translating code, or explaining complex snippets? IDX AI has you covered. It even highlights potential license requirements based on the generated code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Effortless Project Creation&lt;/strong&gt;&lt;br&gt;
Say goodbye to the tedium of starting new projects. IDX supports various frameworks like Angular, Flutter, Next.js, React, Svelte, and Vue, offering templates that make starting your desired app a breeze, all directly from your browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. GitHub Integration&lt;/strong&gt;&lt;br&gt;
Bring your existing projects into IDX or kickstart your work from public or private GitHub repositories. Seamless integration ensures a smooth transition from your current development setup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Built-In Emulators and Simulators&lt;/strong&gt;&lt;br&gt;
Developing Flutter apps? IDX comes equipped with Android emulators and iOS simulators right in your workspace. Check your changes and streamline your Flutter development process effortlessly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Direct Deployment&lt;/strong&gt;&lt;br&gt;
Deploy your web or Flutter web projects directly to Firebase Hosting from your IDX workspace, eliminating the need for additional steps in the deployment pipeline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Collaborative Workspace Sharing (Experimental)&lt;/strong&gt;&lt;br&gt;
IDX takes collaboration to the next level. Experiment with the experimental workspace sharing feature, inviting others to your workspace with shared access to code, terminals, emulators, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Full VM Workspaces&lt;/strong&gt;&lt;br&gt;
Configure, reproduce, and enjoy ephemeral IDX workspaces that allow you to code from anywhere with a clean, powerful developer setup.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. Extensions for Enhanced Productivity&lt;/strong&gt;&lt;br&gt;
IDX comes pre-loaded with extensions to assist you in setting up your workspace. Additionally, explore a variety of extensions available from OpenVSX, enhancing your productivity further.&lt;/p&gt;

&lt;p&gt;Unveiling Project IDX: A Game-Changing Coding Playground&lt;br&gt;
Hey fellow devs, brace yourselves for a coding revolution with Project IDX! It's not your ordinary IDE; think of it as your coding sanctuary, making the whole process smoother and more enjoyable. No more grappling with complex setups – IDX has got your back!&lt;/p&gt;

&lt;p&gt;Decoding Project IDX:&lt;br&gt;
Imagine Project IDX as a virtual haven for coding, accessible right from your web browser. No fuss, no setup headaches – just pure coding goodness.&lt;/p&gt;

&lt;p&gt;The Cool Features:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Familiarity is Key&lt;br&gt;
Ever get that warm and fuzzy feeling using your favorite coding tools? IDX brings you that comfort, built on the foundation of Code OSS. It's like a reliable companion for developers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your Coding Sidekick - IDX AI&lt;br&gt;
Say hello to your new coding companion, IDX AI! This intelligent assistant lends a helping hand with code suggestions, translations, and unraveling tricky code. Need a coding buddy? IDX AI has got your back!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Effortless Project Kickoff&lt;br&gt;
Starting a new project doesn't have to be a headache. IDX comes with special templates for various projects – websites, mobile apps, you name it. Just a click, and you're good to go!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;GitHub Integration Magic&lt;br&gt;
Already have cool projects on GitHub? IDX works its magic, bringing them into the mix. It's like your GitHub projects seamlessly joining the IDX party.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Play with Emulators&lt;br&gt;
Developing apps for your phone? IDX has built-in play areas for Android and iPhone apps. It's like having virtual phones right on your computer – pretty slick!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Showcase Your Work&lt;br&gt;
Done creating something awesome? With IDX, flaunt your work to others. It's akin to inviting friends to witness your coding prowess, and they can even pitch in if you're up for it!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Streamlined Deployment&lt;br&gt;
Getting your app out there can be tricky, but not with IDX. Send your website or app straight to the internet using Firebase. It's like a shortcut for showcasing your creations!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Collaborative Workspace (Still in the Learning Phase!)&lt;br&gt;
Here's something brand new – invite friends to your coding space! They can see what you're doing, and you can work together. It's like having a coding party online.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Personalize Your Coding Space&lt;br&gt;
Just like decorating your laptop, IDX lets you add cool things to your coding space, making it uniquely yours. Plus, there are extra tools you can add to enhance your coding experience!&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Points to Remember:&lt;/strong&gt;&lt;br&gt;
Before you embark on your IDX journey, heed the cautionary notes. Project IDX is an experimental release, subject to change without notice. It's not intended for production use, but rather an exploration of a new paradigm in app development.&lt;br&gt;
The AI generative code features and Android emulators support come with additional restrictions and disclaimers, emphasizing responsible usage and adherence to specified terms and conditions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Join the Revolution:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Get Started with Project IDX&lt;br&gt;
Ready to experience the future of development? Join the waitlist and be part of the revolution. Whether you're an AI enthusiast, a seasoned developer, or a curious learner, Project IDX promises to reshape your coding experience.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>idx</category>
      <category>programming</category>
      <category>googlecloud</category>
    </item>
    <item>
      <title>Optimizing React Application Performance: Best Practices for MERN Stack Developers</title>
      <dc:creator>Dev Raj Sharma</dc:creator>
      <pubDate>Tue, 09 Jan 2024 06:08:35 +0000</pubDate>
      <link>https://forem.com/codewithsharma/optimizing-react-application-performance-best-practices-for-mern-stack-developers-5c48</link>
      <guid>https://forem.com/codewithsharma/optimizing-react-application-performance-best-practices-for-mern-stack-developers-5c48</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the fast-paced world of web development, optimizing the performance of your React applications is crucial for delivering a seamless user experience. As MERN (MongoDB, Express.js, React, Node.js) Stack Developers, it's essential to adopt best practices that not only enhance the speed of your applications but also contribute to overall user satisfaction.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Code Splitting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What is Code Splitting?&lt;/strong&gt;&lt;br&gt;
Code splitting is a technique that involves breaking down your JavaScript bundle into smaller, more manageable chunks. By loading only the necessary code for a particular view or feature, you can significantly reduce the initial page load time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to Implement Code Splitting in MERN&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use React.lazy and Suspense for dynamic imports of components.&lt;/li&gt;
&lt;li&gt;Identify and split large libraries or components that are not immediately needed.&lt;/li&gt;
&lt;li&gt;Leverage tools like Webpack for seamless integration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Real-World Scenarios&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Loading specific components only when a user navigates to a certain route.&lt;/li&gt;
&lt;li&gt;Optimizing the loading of heavy third-party libraries on demand.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Memoization Techniques
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Understanding Memoization&lt;/strong&gt;&lt;br&gt;
Memoization involves caching the results of expensive function calls and returning the cached result when the same inputs occur again. In React, this can prevent unnecessary re-renders and enhance overall application performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using useMemo and useCallback&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;useMemo&lt;/code&gt; to memoize the result of expensive computations within functional components.&lt;/li&gt;
&lt;li&gt;Apply &lt;code&gt;useCallback&lt;/code&gt; to memoize callback functions, preventing unnecessary recreation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Scenarios for Memoization&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Components depending on dynamic data that doesn't change frequently.&lt;/li&gt;
&lt;li&gt;Callback functions passed down to child components that remain constant.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Lazy Loading
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Significance of Lazy Loadi&lt;/strong&gt;ng&lt;/p&gt;

&lt;p&gt;Lazy loading is the practice of deferring the loading of non-essential resources until they are actually needed. This is particularly impactful in reducing the initial load time of your React application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Implementation in MERN&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implement dynamic imports for components that are not critical for the initial view.&lt;/li&gt;
&lt;li&gt;Consider server-side rendering (SSR) to optimize the first meaningful paint.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Impact on Initial Page Load&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster loading times, especially for large-scale applications.&lt;/li&gt;
&lt;li&gt;Improved perceived performance leading to better user engagement.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Efficient Data Fetching
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Best Practices for Data Fetching&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Minimize unnecessary data fetching by fetching only what is needed for a particular view.&lt;/li&gt;
&lt;li&gt;Implement pagination and caching strategies to optimize API calls.&lt;/li&gt;
&lt;li&gt;Handle large datasets efficiently, considering factors like virtualization.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Practical Examples&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetching only essential user data on the dashboard.&lt;/li&gt;
&lt;li&gt;Implementing a caching mechanism to store frequently accessed API responses.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Bundle Size Optimization
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Analyzing and Reducing Bundle Size&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Employ tools like tree shaking to eliminate unused code.&lt;/li&gt;
&lt;li&gt;Minify and compress JavaScript files to reduce overall bundle size.&lt;/li&gt;
&lt;li&gt;Strike a balance between code splitting for performance and its impact on bundle size.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tips for Developers&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Regularly analyze and audit your bundle size.&lt;/li&gt;
&lt;li&gt;Prioritize critical code paths for optimization.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In the dynamic landscape of MERN stack development, optimizing React application performance is an ongoing journey. By implementing these best practices, MERN stack developers can not only create faster, more responsive applications but also contribute to a positive user experience. Stay informed about emerging optimization techniques and tools to ensure your applications remain at the forefront of performance standards. Remember, a well-optimized application is a key driver of user satisfaction and retention. Happy coding!&lt;/p&gt;
&lt;/blockquote&gt;

</description>
    </item>
    <item>
      <title>forEach() vs map() in JavaScript</title>
      <dc:creator>Dev Raj Sharma</dc:creator>
      <pubDate>Mon, 08 Jan 2024 10:34:25 +0000</pubDate>
      <link>https://forem.com/codewithsharma/foreach-vs-map-in-javascript-41p6</link>
      <guid>https://forem.com/codewithsharma/foreach-vs-map-in-javascript-41p6</guid>
      <description>&lt;h2&gt;
  
  
  Map() function
&lt;/h2&gt;

&lt;p&gt;In JavaScript, the map function is a higher-order function that is used to create a new array by applying a provided function to each element of an existing array. The original array remains unchanged. The map function takes a callback function as its argument, and this callback function is applied to each element of the array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here's a basic syntax for the map() function&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;code&gt;let newArray = originalArray.map(callbackFunction);&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Square of each elelment of an array&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;You can also use arrow functions for a more concise syntax:&lt;/strong&gt;&lt;/p&gt;

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

&lt;h2&gt;
  
  
  forEach() method
&lt;/h2&gt;

&lt;p&gt;In JavaScript, the forEach method is used to iterate over elements in an array. It provides a concise way to loop through each element of an array and perform a specified operation for each element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here's a basic syntax of the forEach() method:&lt;/strong&gt;&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="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;span class="c1"&gt;// Your code here});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Here's an example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qbfgxbib2wuv5g51qmp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6qbfgxbib2wuv5g51qmp.png" alt="forEach()function"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happen if we try to modify the array using forEach()&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;The output Will be undefined.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Correct approach of doing it.&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;When to use which&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your use case will determine whether to use &lt;code&gt;map()&lt;/code&gt; or &lt;code&gt;forEach()&lt;/code&gt;. The &lt;code&gt;map()&lt;/code&gt; provides a new array containing the transformed data, thus you should use it if you intend to modify, alternate, or use the data.But instead of using &lt;code&gt;map()&lt;/code&gt;, use &lt;code&gt;forEach()&lt;/code&gt; if you won’t require the resulting array.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>codewithsharma</category>
    </item>
    <item>
      <title>Basic Array Methods In JavaScript.</title>
      <dc:creator>Dev Raj Sharma</dc:creator>
      <pubDate>Sun, 07 Jan 2024 07:53:22 +0000</pubDate>
      <link>https://forem.com/codewithsharma/basic-array-methods-in-javascript-23mg</link>
      <guid>https://forem.com/codewithsharma/basic-array-methods-in-javascript-23mg</guid>
      <description>&lt;p&gt;&lt;strong&gt;Lets Create An Array of Integers&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;let numbers = [5, 1, 7, 3];&lt;br&gt;
console.log(numbers);&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;[ 5, 1, 7, 3 ]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.  Finding the length of the Array&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;let lengthOfArray = numbers.length;&lt;br&gt;
console.log(lengthOfArray);&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;4&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.  Sortng the array in ascending order&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;numbers.sort();&lt;br&gt;
console.log(numbers);&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;[ 1, 3, 5, 7 ]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Adding new element in last of the index&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;numbers.push(6);&lt;br&gt;
console.log(numbers)&lt;/code&gt;; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;[ 1, 3, 5, 7, 6 ]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.  Adding new Element in starting of the array&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;numbers.unshift(8);&lt;br&gt;
console.log(numbers);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[ 8, 1, 3, 5, 7, 6 ]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.  Removing or Deeleting a first element of the array&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;numbers.shift();&lt;br&gt;
console.log(numbers);&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;[ 1, 3, 5, 7, 6 ]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.  Removing or Deleting a last element of the array&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;numbers.pop();&lt;br&gt;
console.log(numbers);&lt;/code&gt; &lt;br&gt;
&lt;em&gt;[ 1, 3, 5, 7 ]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Finding element of the targeted index&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let index = 2;&lt;br&gt;
console.log(At index of ${index} element is ${numbers.at(index)});&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;At index of 2 element is 5&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Merging two or more array&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;const array1 = [1,2,3,4,5];&lt;br&gt;
const array2 = [6,7,8,9];&lt;br&gt;
const newArray = array1.concat(array2);&lt;br&gt;
console.log(newArray)&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;[1, 2, 3, 4, 5 ,6, 7, 8, 9]&lt;/em&gt;&lt;/p&gt;

</description>
      <category>arraymethods</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
