<?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: Code X Savage</title>
    <description>The latest articles on DEV Community by Code X Savage (@codexsavage6s).</description>
    <link>https://dev.to/codexsavage6s</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4006354%2F128f2de1-68b0-4fcc-a20d-b99209b500da.png</url>
      <title>DEV Community: Code X Savage</title>
      <link>https://dev.to/codexsavage6s</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codexsavage6s"/>
    <language>en</language>
    <item>
      <title>Editing Text Contents with DOM</title>
      <dc:creator>Code X Savage</dc:creator>
      <pubDate>Tue, 28 Jul 2026 14:50:43 +0000</pubDate>
      <link>https://dev.to/codexsavage6s/editing-text-contents-with-dom-1a2e</link>
      <guid>https://dev.to/codexsavage6s/editing-text-contents-with-dom-1a2e</guid>
      <description>&lt;p&gt;One of the biggest misconceptions I had when learning JavaScript was thinking that the DOM and HTML were the same thing.&lt;/p&gt;

&lt;p&gt;They aren't.&lt;/p&gt;

&lt;p&gt;When I first started manipulating web pages, I kept hearing things like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Use &lt;code&gt;querySelector()&lt;/code&gt; to select an element from the DOM."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My first thought was:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"Isn't it just selecting the HTML?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It turns out there's an important difference, and understanding that difference makes JavaScript much easier to reason about.&lt;/p&gt;

&lt;p&gt;Let's break it down.&lt;/p&gt;




&lt;h1&gt;
  
  
  HTML vs The DOM
&lt;/h1&gt;

&lt;p&gt;HTML is simply a text document.&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;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Hello World&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Welcome to my website.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all it is.&lt;/p&gt;

&lt;p&gt;A text file.&lt;/p&gt;

&lt;p&gt;Your browser then reads that file and creates something called the &lt;strong&gt;Document Object Model (DOM).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Think of the DOM as a live representation of your HTML that JavaScript can interact with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Document
│
└── body
    ├── h1
    │   └── "Hello World"
    │
    └── p
        └── "Welcome to my website."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript never edits your original HTML file.&lt;/p&gt;

&lt;p&gt;Instead, it manipulates this DOM tree.&lt;/p&gt;

&lt;p&gt;That's why when you inspect a page in your browser, you'll often see changes that don't exist inside your original HTML file.&lt;/p&gt;




&lt;h1&gt;
  
  
  Selecting Elements
&lt;/h1&gt;

&lt;p&gt;Once the DOM has been created, JavaScript can find elements.&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;heading&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h1&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;Now you have access to that DOM node.&lt;/p&gt;

&lt;p&gt;From here you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change text&lt;/li&gt;
&lt;li&gt;Change styles&lt;/li&gt;
&lt;li&gt;Add classes&lt;/li&gt;
&lt;li&gt;Remove elements&lt;/li&gt;
&lt;li&gt;Create new elements&lt;/li&gt;
&lt;li&gt;Listen for events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is what people mean when they say JavaScript manipulates the DOM.&lt;/p&gt;




&lt;h1&gt;
  
  
  Changing Content
&lt;/h1&gt;

&lt;p&gt;This is where many beginners get confused.&lt;/p&gt;

&lt;p&gt;JavaScript gives us multiple ways to change an element's content.&lt;/p&gt;

&lt;p&gt;The three you'll encounter the most are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;innerHTML&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;innerText&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;textContent&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At first glance they seem similar.&lt;/p&gt;

&lt;p&gt;They're not.&lt;/p&gt;




&lt;h1&gt;
  
  
  1. innerHTML
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;innerHTML&lt;/code&gt; reads or writes HTML inside an element.&lt;/p&gt;

&lt;p&gt;Example:&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;id=&lt;/span&gt;&lt;span class="s"&gt;"box"&lt;/span&gt;&lt;span class="nt"&gt;&amp;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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;box&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;box&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;box&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;h2&amp;gt;Hello&amp;lt;/h2&amp;gt;&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;The browser creates an actual &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;Result:&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;id=&lt;/span&gt;&lt;span class="s"&gt;"box"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Hello&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes &lt;code&gt;innerHTML&lt;/code&gt; incredibly powerful.&lt;/p&gt;




&lt;h2&gt;
  
  
  Pros
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Can create HTML dynamically.&lt;/li&gt;
&lt;li&gt;Useful for rendering templates.&lt;/li&gt;
&lt;li&gt;Great for inserting multiple elements at once.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Cons
&lt;/h2&gt;

&lt;p&gt;If the content comes from user input, using &lt;code&gt;innerHTML&lt;/code&gt; carelessly can introduce security issues, such as executing unwanted HTML or scripts.&lt;/p&gt;

&lt;p&gt;It also causes the browser to parse the HTML again, which can be less efficient than simply changing text.&lt;/p&gt;

&lt;p&gt;For those reasons, avoid using &lt;code&gt;innerHTML&lt;/code&gt; unless you actually need to insert HTML.&lt;/p&gt;




&lt;h1&gt;
  
  
  2. innerText
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;innerText&lt;/code&gt; only works with visible text.&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;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Hello
    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"display:none"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hidden&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/p&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;p&gt;Notice the hidden text isn't included.&lt;/p&gt;

&lt;p&gt;This is because &lt;code&gt;innerText&lt;/code&gt; considers how the page is rendered.&lt;/p&gt;

&lt;p&gt;If something isn't visible to the user, it usually won't appear.&lt;/p&gt;




&lt;h2&gt;
  
  
  Pros
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Reflects what users actually see.&lt;/li&gt;
&lt;li&gt;Great for reading visible text.&lt;/li&gt;
&lt;li&gt;Ignores hidden content.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Cons
&lt;/h2&gt;

&lt;p&gt;Because it considers styling and layout, reading &lt;code&gt;innerText&lt;/code&gt; can require extra work from the browser.&lt;/p&gt;

&lt;p&gt;For large applications, repeatedly using it can be less efficient than &lt;code&gt;textContent&lt;/code&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  3. textContent
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;textContent&lt;/code&gt; retrieves all text inside an element.&lt;/p&gt;

&lt;p&gt;Using the same example:&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;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Hello
    &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"display:none"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hidden&lt;span class="nt"&gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/p&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;p&gt;Unlike &lt;code&gt;innerText&lt;/code&gt;, it doesn't care whether the text is visible.&lt;/p&gt;

&lt;p&gt;It simply returns the raw text contained in the node.&lt;/p&gt;




&lt;h2&gt;
  
  
  Pros
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Faster than &lt;code&gt;innerText&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Includes hidden text.&lt;/li&gt;
&lt;li&gt;Doesn't interpret HTML.&lt;/li&gt;
&lt;li&gt;Safe for inserting plain text.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Cons
&lt;/h2&gt;

&lt;p&gt;It ignores how the page is displayed.&lt;/p&gt;

&lt;p&gt;If you only care about what users can actually see, &lt;code&gt;innerText&lt;/code&gt; may be the better choice.&lt;/p&gt;




&lt;h1&gt;
  
  
  Which One Should You Use?
&lt;/h1&gt;

&lt;p&gt;Here's a simple rule I like to follow.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Use&lt;/th&gt;
&lt;th&gt;When&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;textContent&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;When you're working with plain text.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;innerText&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;When you specifically need the visible text shown to users.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;innerHTML&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Only when you genuinely need to create or insert HTML.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you're unsure, &lt;strong&gt;start with &lt;code&gt;textContent&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's safer and usually the better default.&lt;/p&gt;




&lt;h1&gt;
  
  
  A Common Beginner Mistake
&lt;/h1&gt;

&lt;p&gt;When I first learned JavaScript, I used &lt;code&gt;innerHTML&lt;/code&gt; for almost everything.&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;heading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Later I realised I wasn't inserting HTML.&lt;/p&gt;

&lt;p&gt;I was only displaying text.&lt;/p&gt;

&lt;p&gt;This is a much better choice:&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;heading&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's simpler, safer, and communicates your intention more clearly.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Understanding the DOM isn't just about learning methods like &lt;code&gt;querySelector()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It's about understanding &lt;strong&gt;what JavaScript is actually manipulating.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The browser converts your HTML into a DOM tree.&lt;/p&gt;

&lt;p&gt;JavaScript interacts with that tree.&lt;/p&gt;

&lt;p&gt;And choosing the right property—&lt;code&gt;innerHTML&lt;/code&gt;, &lt;code&gt;innerText&lt;/code&gt;, or &lt;code&gt;textContent&lt;/code&gt;—depends on what you're trying to achieve.&lt;/p&gt;

&lt;p&gt;The more you understand these differences, the more confident you'll become when building interactive web applications.&lt;/p&gt;




&lt;h2&gt;
  
  
  What About You?
&lt;/h2&gt;

&lt;p&gt;When you first started learning JavaScript, which one confused you the most?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;innerHTML&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;innerText&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;textContent&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'd love to hear your experience in the comments.&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>learning</category>
      <category>frontend</category>
    </item>
    <item>
      <title>React Components Aren't Magic—They're Built on a JavaScript Mindset</title>
      <dc:creator>Code X Savage</dc:creator>
      <pubDate>Wed, 22 Jul 2026 21:58:04 +0000</pubDate>
      <link>https://dev.to/codexsavage6s/react-components-arent-magic-theyre-built-on-a-javascript-mindset-46ic</link>
      <guid>https://dev.to/codexsavage6s/react-components-arent-magic-theyre-built-on-a-javascript-mindset-46ic</guid>
      <description>&lt;h3&gt;
  
  
  Before You Learn React, Master This JavaScript Habit
&lt;/h3&gt;

&lt;p&gt;When I first started learning React, everyone kept talking about &lt;strong&gt;components&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Components this.&lt;/p&gt;

&lt;p&gt;Components that.&lt;/p&gt;

&lt;p&gt;At first, I thought components were something unique to React.&lt;/p&gt;

&lt;p&gt;But after spending more time with vanilla JavaScript, I realized something.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The mindset behind React components already exists in JavaScript.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React didn't invent reusability—it simply gave it a better structure.&lt;/p&gt;

&lt;p&gt;If you're planning to learn React after JavaScript, there's one habit worth building now:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Write reusable code.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Why Reusability Matters
&lt;/h2&gt;

&lt;p&gt;Imagine you're building a dashboard.&lt;/p&gt;

&lt;p&gt;It has five buttons.&lt;/p&gt;

&lt;p&gt;Every button shares the same styling and almost the same behavior.&lt;/p&gt;

&lt;p&gt;One approach would be to copy and paste the same code five times.&lt;/p&gt;

&lt;p&gt;It works...&lt;/p&gt;

&lt;p&gt;Until you want to change something.&lt;/p&gt;

&lt;p&gt;Now you're editing five different places.&lt;/p&gt;

&lt;p&gt;Maybe you decide to change the button color.&lt;/p&gt;

&lt;p&gt;Or the padding.&lt;/p&gt;

&lt;p&gt;Or add an icon.&lt;/p&gt;

&lt;p&gt;Now every copy needs to be updated.&lt;/p&gt;

&lt;p&gt;This is where reusable code shines.&lt;/p&gt;

&lt;p&gt;Write it once.&lt;/p&gt;

&lt;p&gt;Use it everywhere.&lt;/p&gt;

&lt;p&gt;Besides saving time, reusable code makes your projects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easier to maintain&lt;/li&gt;
&lt;li&gt;Easier to debug&lt;/li&gt;
&lt;li&gt;Easier to extend&lt;/li&gt;
&lt;li&gt;Easier for other developers to understand&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  JavaScript Already Supports This
&lt;/h2&gt;

&lt;p&gt;When people hear the word &lt;strong&gt;component&lt;/strong&gt;, they immediately think of React.&lt;/p&gt;

&lt;p&gt;But JavaScript has supported reusable logic for years through functions.&lt;/p&gt;

&lt;p&gt;For example:&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;function&lt;/span&gt; &lt;span class="nf"&gt;createButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&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;button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;btn&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;button&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;p&gt;Instead of writing this repeatedly:&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;saveBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;saveBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Save&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;deleteBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;deleteBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Delete&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;cancelBtn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;cancelBtn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cancel&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;You simply reuse your 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="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nf"&gt;createButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Save&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nf"&gt;createButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Delete&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nf"&gt;createButton&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Cancel&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;p&gt;One function.&lt;/p&gt;

&lt;p&gt;Multiple buttons.&lt;/p&gt;

&lt;p&gt;Same logic.&lt;/p&gt;




&lt;h2&gt;
  
  
  This Is The Mindset React Builds On
&lt;/h2&gt;

&lt;p&gt;Now look at React.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Save"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Delete"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Cancel"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Different syntax.&lt;/p&gt;

&lt;p&gt;Same principle.&lt;/p&gt;

&lt;p&gt;React components are simply reusable pieces of UI.&lt;/p&gt;

&lt;p&gt;Instead of returning DOM elements directly, React components return JSX.&lt;/p&gt;

&lt;p&gt;The idea, however, is exactly the same:&lt;/p&gt;

&lt;p&gt;Create something once.&lt;/p&gt;

&lt;p&gt;Reuse it whenever you need it.&lt;/p&gt;




&lt;h2&gt;
  
  
  React Isn't Magic
&lt;/h2&gt;

&lt;p&gt;One thing that slowed me down when learning React was thinking it introduced an entirely new way of programming.&lt;/p&gt;

&lt;p&gt;It doesn't.&lt;/p&gt;

&lt;p&gt;React is still JavaScript.&lt;/p&gt;

&lt;p&gt;It simply encourages you to organize your UI into reusable, self-contained pieces called components.&lt;/p&gt;

&lt;p&gt;Once I stopped thinking of components as something magical, React became much easier to understand.&lt;/p&gt;




&lt;h2&gt;
  
  
  What You Should Practice Before React
&lt;/h2&gt;

&lt;p&gt;If you're currently learning vanilla JavaScript, I think there are a few habits worth developing before moving to React.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write reusable functions.&lt;/li&gt;
&lt;li&gt;Break large problems into smaller ones.&lt;/li&gt;
&lt;li&gt;Avoid copying and pasting code.&lt;/li&gt;
&lt;li&gt;Keep related logic together.&lt;/li&gt;
&lt;li&gt;Think about maintainability instead of just making things work.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These habits transfer directly into React development.&lt;/p&gt;




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

&lt;p&gt;Many beginners rush into React because it's popular.&lt;/p&gt;

&lt;p&gt;There's nothing wrong with that.&lt;/p&gt;

&lt;p&gt;But if you spend time mastering reusable functions in vanilla JavaScript first, React starts to feel much more familiar.&lt;/p&gt;

&lt;p&gt;You'll spend less time wondering &lt;strong&gt;"What is a component?"&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And more time appreciating &lt;strong&gt;why components exist.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React didn't invent reusability.&lt;/p&gt;

&lt;p&gt;It simply built an entire library around a mindset JavaScript already encourages.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What do you think?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you've already learned React, did understanding JavaScript functions make components easier to understand?&lt;/p&gt;

&lt;p&gt;I'd love to hear your thoughts.&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>frontend</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>Is Typescript worth it?</title>
      <dc:creator>Code X Savage</dc:creator>
      <pubDate>Sat, 18 Jul 2026 01:16:17 +0000</pubDate>
      <link>https://dev.to/codexsavage6s/is-typescript-worth-it-29m8</link>
      <guid>https://dev.to/codexsavage6s/is-typescript-worth-it-29m8</guid>
      <description>&lt;h1&gt;
  
  
  Is TypeScript Really Worth Learning?
&lt;/h1&gt;

&lt;p&gt;When I first started learning TypeScript, I honestly didn't understand the hype.&lt;/p&gt;

&lt;p&gt;I thought:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"If I'm the one writing the code, then I already know what type every variable should be... so why do I need TypeScript?"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It just looked like JavaScript with more syntax.&lt;/p&gt;

&lt;p&gt;After spending more time with it while building my SaaS, I started to understand why so many developers recommend it.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Exactly Is TypeScript?
&lt;/h2&gt;

&lt;p&gt;TypeScript isn't a completely new programming language.&lt;/p&gt;

&lt;p&gt;It's a &lt;strong&gt;superset of JavaScript&lt;/strong&gt; that adds &lt;strong&gt;static typing&lt;/strong&gt; and better developer tooling while compiling down to plain JavaScript.&lt;/p&gt;

&lt;p&gt;If you already know JavaScript, you're already most of the way there.&lt;/p&gt;




&lt;h2&gt;
  
  
  So What Is Type Safety?
&lt;/h2&gt;

&lt;p&gt;Imagine you have a function that expects a string.&lt;/p&gt;

&lt;p&gt;In JavaScript, you could accidentally pass a number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&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;Hello &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript won't complain immediately.&lt;/p&gt;

&lt;p&gt;Now look at the same example in TypeScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&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="s2"&gt;`Hello &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your editor immediately highlights the error before you even run the application.&lt;/p&gt;

&lt;p&gt;That means you can catch bugs much earlier instead of discovering them later during testing—or worse, in production.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why I Was Hesitant
&lt;/h2&gt;

&lt;p&gt;I could definitely see the benefits when working in a team.&lt;/p&gt;

&lt;p&gt;If everyone follows the same types, it becomes much harder to accidentally pass the wrong data around.&lt;/p&gt;

&lt;p&gt;But as someone building solo, I kept asking myself:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Do I really need all of this?"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'll admit...&lt;/p&gt;

&lt;p&gt;Part of it was just laziness.&lt;/p&gt;

&lt;p&gt;Writing types felt like extra work.&lt;/p&gt;




&lt;h2&gt;
  
  
  Then Came My First Next.js Deployment...
&lt;/h2&gt;

&lt;p&gt;This was probably the moment that changed my opinion.&lt;/p&gt;

&lt;p&gt;While deploying my Next.js project, TypeScript started complaining about issues I had ignored during development.&lt;/p&gt;

&lt;p&gt;It was frustrating.&lt;/p&gt;

&lt;p&gt;At one point I seriously thought:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Why is this making deployment so much harder?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But after fixing those issues, I realized something.&lt;/p&gt;

&lt;p&gt;TypeScript wasn't creating bugs.&lt;/p&gt;

&lt;p&gt;It was forcing me to fix bugs &lt;strong&gt;before&lt;/strong&gt; users ever saw them.&lt;/p&gt;

&lt;p&gt;Looking back, that's exactly what I want from my tooling.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Downsides
&lt;/h2&gt;

&lt;p&gt;TypeScript isn't perfect.&lt;/p&gt;

&lt;p&gt;Some of the things I still find annoying are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Writing extra type definitions.&lt;/li&gt;
&lt;li&gt;Spending time fixing compiler errors.&lt;/li&gt;
&lt;li&gt;Feeling like there's more boilerplate than plain JavaScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're building a quick prototype, JavaScript often feels faster.&lt;/p&gt;




&lt;h2&gt;
  
  
  So... Is It Worth It?
&lt;/h2&gt;

&lt;p&gt;For small personal projects, JavaScript is still an excellent choice.&lt;/p&gt;

&lt;p&gt;But for larger applications—or anything you expect to maintain for months or years—I now understand why TypeScript has become the standard for so many teams.&lt;/p&gt;

&lt;p&gt;Yes, it slows you down a little at first.&lt;/p&gt;

&lt;p&gt;But it can save you hours of debugging later.&lt;/p&gt;

&lt;p&gt;For me, the trade-off is worth it.&lt;/p&gt;




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

&lt;p&gt;When I started learning TypeScript, I saw it as unnecessary complexity.&lt;/p&gt;

&lt;p&gt;Now I see it as an investment.&lt;/p&gt;

&lt;p&gt;It catches mistakes early, makes code easier to understand, and gives me more confidence when building larger projects like my SaaS.&lt;/p&gt;

&lt;p&gt;I'm still learning it every day, but I'm glad I stuck with it.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What about you?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What's one thing TypeScript changed about the way you write JavaScript?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By the way this is just my personal opinion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'd love to hear your experience in the comments.&lt;/p&gt;




</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>learning</category>
      <category>programming</category>
    </item>
    <item>
      <title>5 JavaScript Features I Wish I Had Learned Earlier</title>
      <dc:creator>Code X Savage</dc:creator>
      <pubDate>Thu, 16 Jul 2026 23:16:40 +0000</pubDate>
      <link>https://dev.to/codexsavage6s/5-javascript-features-i-wish-i-had-learned-earlier-1lpa</link>
      <guid>https://dev.to/codexsavage6s/5-javascript-features-i-wish-i-had-learned-earlier-1lpa</guid>
      <description>&lt;p&gt;JavaScript is one of those languages where you can build a lot without knowing every feature. But as I continue building projects, I've come across a few features that make my code cleaner and easier to maintain.&lt;/p&gt;

&lt;p&gt;Here are five JavaScript features I wish I had learned much earlier.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Optional Chaining (&lt;code&gt;?.&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;Accessing nested properties used to look like this:&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;city&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it becomes:&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;city&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If any property doesn't exist, JavaScript simply returns &lt;code&gt;undefined&lt;/code&gt; instead of throwing an error.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Nullish Coalescing (&lt;code&gt;??&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;Many developers use &lt;code&gt;||&lt;/code&gt;, but it can produce unexpected results.&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;username&lt;/span&gt; &lt;span class="o"&gt;=&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Guest&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Guest&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sometimes an empty string is a valid value.&lt;/p&gt;

&lt;p&gt;Using &lt;code&gt;??&lt;/code&gt; fixes that:&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;username&lt;/span&gt; &lt;span class="o"&gt;=&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Guest&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// ""&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;??&lt;/code&gt; only falls back when the value is &lt;code&gt;null&lt;/code&gt; or &lt;code&gt;undefined&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Destructuring
&lt;/h2&gt;

&lt;p&gt;Instead of writing:&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&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;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can write:&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's cleaner and scales much better.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Spread Operator (&lt;code&gt;...&lt;/code&gt;)
&lt;/h2&gt;

&lt;p&gt;Creating a copy of an array is incredibly easy.&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;numbers&lt;/span&gt; &lt;span class="o"&gt;=&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="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&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;copy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also merge arrays:&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;merged&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;arrayOne&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;arrayTwo&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The spread operator also works with objects:&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;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Alex&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Developer&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;updatedUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Senior Developer&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;h2&gt;
  
  
  5. Array Methods
&lt;/h2&gt;

&lt;p&gt;Instead of traditional loops:&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="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&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;p&gt;Modern JavaScript provides expressive methods:&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;users&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="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&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;activeUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;active&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;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These methods often make your code easier to read.&lt;/p&gt;




&lt;h2&gt;
  
  
  Bonus Tip: Template Literals
&lt;/h2&gt;

&lt;p&gt;Instead of concatenating strings:&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;greeting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;!&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;You can use template literals:&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;greeting&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Hello, &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;!`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They're cleaner and especially useful for multi-line strings.&lt;/p&gt;




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

&lt;p&gt;Learning JavaScript isn't about memorizing every feature.&lt;/p&gt;

&lt;p&gt;It's about gradually discovering tools that help you write cleaner, more maintainable code.&lt;/p&gt;

&lt;p&gt;The more projects you build, the more these features start to feel like second nature.&lt;/p&gt;

&lt;p&gt;Which JavaScript feature do you wish you had learned earlier? Let me know in the comments!&lt;/p&gt;




</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>beginners</category>
    </item>
    <item>
      <title>I Spent Hours Debugging better-auth OAuth… Because I Overthought It</title>
      <dc:creator>Code X Savage</dc:creator>
      <pubDate>Thu, 02 Jul 2026 19:47:15 +0000</pubDate>
      <link>https://dev.to/codexsavage6s/i-spent-hours-debugging-better-auth-oauth-because-i-overthought-it-1j9b</link>
      <guid>https://dev.to/codexsavage6s/i-spent-hours-debugging-better-auth-oauth-because-i-overthought-it-1j9b</guid>
      <description>&lt;p&gt;We’ve all been there: you’re building a Next.js app, hit a wall, and spend hours questioning your entire tech stack—only to realize you overthought the whole thing.&lt;br&gt;
​Recently, I was setting up Google OAuth using better-auth. I followed the docs, which clearly showed the authClient.signIn.social() method.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;​The Next.js Rabbit Hole&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
​My brain made an assumption: "If there is a sign-in endpoint, there must be a separate sign-up endpoint for new users." Believing this, I spent hours debugging and pointing fingers at everything:&lt;br&gt;
​Is better-auth bugged?&lt;br&gt;
​Is react-hook-form failing to pass data?&lt;br&gt;
​Is my database schema blocking new users?&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;​The Fix&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
​I completely overthought it. In better-auth, signIn handles both sign-in AND sign-up automatically. If a user doesn't exist, it creates them. There is no separate sign-up endpoint for OAuth. I was just hitting the wrong endpoint.&lt;br&gt;
​The Lesson&lt;br&gt;
​If the docs only show one method for OAuth, trust it! It does it all.&lt;br&gt;
​Save yourself the headache and don't look for a sign-up endpoint that doesn't exist. 😂&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>webdev</category>
      <category>oauth</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
