<?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: Slaven Đervida</title>
    <description>The latest articles on DEV Community by Slaven Đervida (@ervidaslaven).</description>
    <link>https://dev.to/ervidaslaven</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%2F181428%2F269ed129-c5e7-46bb-8115-b89469ecddeb.jpeg</url>
      <title>DEV Community: Slaven Đervida</title>
      <link>https://dev.to/ervidaslaven</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ervidaslaven"/>
    <language>en</language>
    <item>
      <title>Unveiling the JavaScript FormData API: A Hidden Gem</title>
      <dc:creator>Slaven Đervida</dc:creator>
      <pubDate>Thu, 14 Sep 2023 20:34:49 +0000</pubDate>
      <link>https://dev.to/ervidaslaven/unveiling-the-javascript-formdata-api-a-hidden-gem-1m31</link>
      <guid>https://dev.to/ervidaslaven/unveiling-the-javascript-formdata-api-a-hidden-gem-1m31</guid>
      <description>&lt;p&gt;In the vast ecosystem of JavaScript, there are countless libraries, frameworks, and built-in APIs. Some are more popular than others, and some, despite their utility, remain relatively obscure. One such underrated feature is the JavaScript &lt;code&gt;FormData&lt;/code&gt; API. This article will shed light on its importance, how it works, and the potential benefits of using it, especially in relation to React's state management.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the FormData API?
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;FormData&lt;/code&gt; API provides a way to easily construct a set of key/value pairs representing form fields and their values. This is especially useful when you want to serialize form data to send it as a request to a server or when you want to use form data in JavaScript without necessarily submitting a form.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using the FormData API
&lt;/h2&gt;

&lt;p&gt;To utilize the &lt;code&gt;FormData&lt;/code&gt; API, it's crucial to note that input fields should have a &lt;code&gt;name&lt;/code&gt; attribute. Without this, you won't be able to retrieve the values correctly.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;FormData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;formElement&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here, &lt;code&gt;formElement&lt;/code&gt; refers to the HTML form element. Once you've created a &lt;code&gt;FormData&lt;/code&gt; object, you can retrieve data from it using:&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;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fieldName&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Additionally, if you want to transform this data into an object, JavaScript offers a concise way:&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formDataAsObject&lt;/span&gt; &lt;span class="o"&gt;=&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;fromEntries&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;formData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;With this, you've effortlessly converted your form data into an object that can be easily manipulated or sent to a server.&lt;/p&gt;
&lt;h2&gt;
  
  
  FormData API vs. React State
&lt;/h2&gt;

&lt;p&gt;Now, for those using React, an obvious question might arise: Should we use the built-in state management or lean on the FormData API?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simplicity and Raw Data&lt;/strong&gt;: If your primary goal is to gather raw data from a form and send it without much manipulation, the &lt;code&gt;FormData&lt;/code&gt; API is a straightforward choice. It eliminates the need for setting up individual state variables for each input field.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Integrated Manipulation&lt;/strong&gt;: React's state provides better integration with the UI. If you need real-time validation, complex data manipulations, or interactions that go beyond mere data collection, the built-in state becomes more appealing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance&lt;/strong&gt;: For large forms, using React's state for each input field can lead to many re-renders, potentially affecting performance. &lt;code&gt;FormData&lt;/code&gt; API can be more efficient in such cases, as it doesn't directly tie into the component's re-render cycle.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Flexibility&lt;/strong&gt;: While &lt;code&gt;FormData&lt;/code&gt; is specifically designed for form data, React's state is more versatile and can handle any type of data, not just form-related.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The JavaScript &lt;code&gt;FormData&lt;/code&gt; API is a powerful tool, particularly for scenarios where form data needs to be collected seamlessly. While it doesn’t replace the need for React's state management in all situations, it does offer a simpler alternative for certain use-cases.&lt;/p&gt;

&lt;p&gt;For developers, the choice between the two largely depends on the complexity of the task at hand. For simple form data collection, the &lt;code&gt;FormData&lt;/code&gt; API is an efficient choice. However, when the requirements extend beyond just data collection, React’s state offers a more integrated solution.&lt;/p&gt;

&lt;p&gt;Ultimately, it's essential to understand the tools at your disposal and to make an informed decision based on the specific needs of your project.&lt;/p&gt;

&lt;p&gt;Here is YT short by @CodinginPublic, check it out!&lt;br&gt;
&lt;/p&gt;
&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://www.youtube.com/shorts/ho_30dN-GMM?si=2gdAmum7sGaBiNs_" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--7i-JXiIq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://i.ytimg.com/vi/ho_30dN-GMM/hq2.jpg%3Fsqp%3D-oaymwEoCOADEOgC8quKqQMcGADwAQH4AbYIgAKAD4oCDAgAEAEYMiAZKH8wDw%3D%3D%26rs%3DAOn4CLCvtdP2Y7jbpFHVfDqyxDjEJGpmYw" height="360" class="m-0" width="480"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://www.youtube.com/shorts/ho_30dN-GMM?si=2gdAmum7sGaBiNs_" rel="noopener noreferrer" class="c-link"&gt;
          Get all values from submitted form - YouTube
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          Did you know the formData API in JavaScript will capture all values on a submitted form?!🎨 VSCode Theming- Font: Cascadia Code: https://github.com/microsoft...
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://res.cloudinary.com/practicaldev/image/fetch/s--_PyUMz1o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://www.youtube.com/s/desktop/a6a78e6c/img/favicon.ico" width="16" height="16"&gt;
        youtube.com
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
      <category>react</category>
    </item>
    <item>
      <title>Bun 1.0: The Swift Newcomer in the JavaScript Ecosystem</title>
      <dc:creator>Slaven Đervida</dc:creator>
      <pubDate>Mon, 11 Sep 2023 14:27:52 +0000</pubDate>
      <link>https://dev.to/ervidaslaven/bun-10-the-swift-newcomer-in-the-javascript-ecosystem-3ol9</link>
      <guid>https://dev.to/ervidaslaven/bun-10-the-swift-newcomer-in-the-javascript-ecosystem-3ol9</guid>
      <description>&lt;p&gt;In a world where web development tools seem to evolve faster than one can keep track, there's always an exciting new player that promises to revolutionize the way we build and deploy applications. Enter Bun 1.0, the fresh face on the block, which has just reached its stable release. This article will dive into what Bun 1.0 is, its impressive features, and how it stacks up against the established tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Bun 1.0?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bun 1.0 is a runtime, much like Node.js, which focuses on delivering speed, efficiency, and a plethora of built-in features. It aims to streamline the development process, eliminating the need for multiple tools that can sometimes introduce unnecessary complexities.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Bun Outpaces Node.js&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UeCc7Bxs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eo6lweb4qa9t3hu1x8y6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UeCc7Bxs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eo6lweb4qa9t3hu1x8y6.png" alt="Node.js VS Bun architecture. [Source](https://inside.caratlane.com/bun-javascript-just-got-faster-211e7d57c61c)" width="720" height="456"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Node.js VS Bun architecture. &lt;a href="https://inside.caratlane.com/bun-javascript-just-got-faster-211e7d57c61c"&gt;Source&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;One of the foremost claims Bun 1.0 makes is its performance advantage over Node.js. Instead of the V8 engine, which powers Node.js, Bun opts for the JavaScript Core Engine, lending it a unique performance and optimization edge. Being written in Zig—a performance-oriented language—it is inherently faster, offering developers quicker compile and run times. For businesses and applications where speed is crucial, this feature alone can be a game-changer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Swiss Army Knife for Developers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the speed was not enough to catch your interest, Bun 1.0 packs in an array of tools:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Built-in Test Runner&lt;/strong&gt;: Gone are the days of integrating third-party test runners. Bun has it out of the box.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integrated Package Manager&lt;/strong&gt;: No more juggling between npm, yarn, or pnpm. Bun 1.0 offers its own package management system.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In-house Bundler&lt;/strong&gt;: Move over webpack and esbuild; Bun provides its own bundling solution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript Compiler&lt;/strong&gt;: A fan favorite among developers, TypeScript has gained immense popularity over the years. Bun 1.0 integrates a built-in TypeScript compiler, making it an even more enticing option.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With these built-in tools, Bun 1.0 is a direct competitor to not just Node.js but also Deno, Vite, Vitest, and the likes. It simplifies the toolchain, reducing overheads and integration challenges.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Future of Bun 1.0&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Given its capabilities and the fact that it is a drop-in replacement for Node, Bun 1.0 is poised to gain significant traction in the near future. Platforms like Vercel and Netlify, which are at the forefront of modern web development, could potentially integrate or offer support for Bun 1.0 soon, given its advantages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Potential Drawbacks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;However, no tool is without its shortcomings. At present, Bun 1.0’s most notable limitation is the absence of a stable version for the Windows operating system. This could be a barrier for developers or organizations that heavily rely on Windows. Yet, with the momentum Bun 1.0 is garnering, it wouldn’t be surprising if we see this issue addressed in upcoming releases.&lt;/p&gt;

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

&lt;p&gt;Bun 1.0 is undeniably an exciting addition to the web development ecosystem. With its speed advantage, courtesy of Zig, and the plethora of built-in tools, it promises a more streamlined and efficient development experience. While the lack of support for Windows is a drawback, the future looks promising for this new contender. Only time will tell if Bun 1.0 can truly disrupt the status quo, but for now, it certainly has the potential and the feature set to make a significant mark.&lt;/p&gt;

&lt;p&gt;Edit: Vercel supports bun install now!&lt;br&gt;
&lt;a href="https://vercel.com/changelog/bun-install-is-now-supported-with-zero-configuration"&gt;Bun install is now supported with zero configuration&lt;/a&gt;&lt;/p&gt;

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