<?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: Arnold Gunter</title>
    <description>The latest articles on DEV Community by Arnold Gunter (@arnoldgunter).</description>
    <link>https://dev.to/arnoldgunter</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%2F3017773%2F25ccc822-56a2-4ee8-bfd7-7cef328ca727.jpeg</url>
      <title>DEV Community: Arnold Gunter</title>
      <link>https://dev.to/arnoldgunter</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/arnoldgunter"/>
    <language>en</language>
    <item>
      <title>Stop Using :valid in Your Forms — Try This New CSS Feature Instead</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Sat, 17 May 2025 15:36:43 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/stop-using-valid-in-your-forms-try-this-new-css-feature-instead-4jlm</link>
      <guid>https://dev.to/arnoldgunter/stop-using-valid-in-your-forms-try-this-new-css-feature-instead-4jlm</guid>
      <description>&lt;p&gt;If you’re a web developer like me, you’ve probably styled a form before.&lt;/p&gt;

&lt;p&gt;And if you’re anything like me, you’ve tried to be helpful — maybe you added some color changes with &lt;code&gt;input:valid&lt;/code&gt; or &lt;code&gt;input:invalid&lt;/code&gt;, outlined fields, maybe even threw in a little transition effect.&lt;/p&gt;

&lt;p&gt;But then this came to your mind: &lt;em&gt;Wait, why is this field showing up as valid before the user even typed anything? 🤦&lt;/em&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;Want smart web dev tips like this delivered straight to your inbox?&lt;br&gt;
JavaScript, CSS, HTML tricks and tools that actually make your life easier.&lt;br&gt;
→ Follow 300+ webdevs, &lt;a href="https://arnold-gunter.kit.com/b33d96a21f?utm-source=devto" rel="noopener noreferrer"&gt;join the newsletter and get your CSS selector cheat sheet for free&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;You try to be nice to users. Give them visual cues. Maybe you change the border color on a valid input, or show a message when they make a mistake.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You think you’re doing a good thing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But then someone opens your form and sees green borders before they’ve even clicked a thing.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Valid already? They didn’t even type! It’s wrong. It feels broken. And worse: it actually is misleading.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s not even talk about accessibility. Using just colors for feedback? That’s a hard “no” if you care about users with color blindness.&lt;/p&gt;




&lt;h2&gt;
  
  
  Here’s the deal
&lt;/h2&gt;

&lt;p&gt;CSS pseudo-classes like &lt;code&gt;:valid&lt;/code&gt; and &lt;code&gt;:invalid&lt;/code&gt; don’t wait for the user to interact.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If the input field meets the required rules on page load (or fails them), the styles apply instantly.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That’s why your untouched email field might already look like a success story. Not cool.&lt;/p&gt;

&lt;h2&gt;
  
  
  But the real solution? It’s brand new:
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Say hello to &lt;code&gt;:user-valid&lt;/code&gt; and &lt;code&gt;:user-invalid.&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These two pseudo-classes work exactly how you always wanted &lt;code&gt;:valid&lt;/code&gt; and &lt;code&gt;:invalid&lt;/code&gt; to behave:&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;They wait for user interaction.&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Nothing changes until the user actually types, blurs, or otherwise engages with the input. Now that’s user-friendly feedback.&lt;/p&gt;

&lt;h2&gt;
  
  
  What It Means For You
&lt;/h2&gt;

&lt;p&gt;If you’re still using &lt;code&gt;:valid/:invalid&lt;/code&gt; on untouched fields, you're frustrating users. They’re seeing red borders before they’ve even typed anything. Or worse—green borders that falsely imply their input is good.&lt;/p&gt;

&lt;p&gt;By switching to &lt;code&gt;:user-valid&lt;/code&gt; and &lt;code&gt;:user-invalid&lt;/code&gt;, your forms become:&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@arnoldgunter/stop-using-valid-in-your-forms-try-this-new-css-feature-instead-05a812db4b4d?sk=cc760b3f0e8ddd5a6a648acbb2518959" rel="noopener noreferrer"&gt;Read the full article here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>tutorial</category>
      <category>html</category>
    </item>
    <item>
      <title>How the NEW Temporal API Finally Fixed JavaScript’s 30-Year Time Problem</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Fri, 09 May 2025 14:48:56 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/how-the-new-temporal-api-finally-fixed-javascripts-30-year-time-problem-cgg</link>
      <guid>https://dev.to/arnoldgunter/how-the-new-temporal-api-finally-fixed-javascripts-30-year-time-problem-cgg</guid>
      <description>&lt;p&gt;Hello folks, I think it was time for this update.&lt;/p&gt;

&lt;p&gt;I mean, you could work with &lt;code&gt;Date&lt;/code&gt;, but it sucks. A lot.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time zone handling was limited and inconsistent&lt;/li&gt;
&lt;li&gt;Parsing behavior was unreliable across browsers&lt;/li&gt;
&lt;li&gt;Mutability. Methods like &lt;code&gt;setDate()&lt;/code&gt; or &lt;code&gt;setMonth()&lt;/code&gt; modified the original object&lt;/li&gt;
&lt;li&gt;Months were zero-based (0 for January), resulting in off-by-one errors&lt;/li&gt;
&lt;li&gt;No support for durations or date arithmetic&lt;/li&gt;
&lt;li&gt;Formatting and localization were inconsistent across browsers&lt;/li&gt;
&lt;li&gt;Calendar systems were not supported… and so on and so forth&lt;/li&gt;
&lt;/ul&gt;




&lt;blockquote&gt;
&lt;p&gt;Want smart web dev tips like this delivered straight to your inbox?&lt;br&gt;
JavaScript, CSS, performance, best practices, and tools like Temporal that actually make your life easier.&lt;br&gt;
→ &lt;a href="https://arnold-gunter.kit.com/b33d96a21f?utm_source=devto" rel="noopener noreferrer"&gt;Follow 300+ webdevs and join the newsletter&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Introducing the New Temporal API
&lt;/h2&gt;

&lt;p&gt;Temporal is a new API introduced in ECMAScript 2022 designed to replace the broken &lt;code&gt;Date&lt;/code&gt; — completely.&lt;/p&gt;

&lt;p&gt;In comparsion to the &lt;code&gt;Date&lt;/code&gt; it is not a Constructor. Temporal is a namespace, like &lt;code&gt;Intl&lt;/code&gt;, which means, you cannot use it with the &lt;code&gt;new&lt;/code&gt; operator or call it as a function as well.&lt;/p&gt;

&lt;p&gt;This provides you with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Immutable data structures&lt;/li&gt;
&lt;li&gt;Precise time zone and calendar control&lt;/li&gt;
&lt;li&gt;Consistent parsing and formatting&lt;/li&gt;
&lt;li&gt;An API design based on value objects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It doesn’t mutate. It doesn’t guess. It doesn’t surprise you.&lt;/p&gt;

&lt;p&gt;Temporal has a complicated but extremely powerful API. &lt;strong&gt;It provides over 200 methods across multiple classes&lt;/strong&gt;, so it can seem very complex.&lt;/p&gt;

&lt;p&gt;But I am here to break down what you really need.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/@arnoldgunter/how-the-new-temporal-api-finally-fixed-javascripts-30-year-time-problem-1875832f565c?sk=792b9076649776fedca566aa17f8e128" rel="noopener noreferrer"&gt;Continue reading the full article here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>news</category>
    </item>
    <item>
      <title>Framework wars are just tech’s version of sports fans arguing over teams they don’t play for.</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Thu, 08 May 2025 13:41:38 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/framework-wars-are-just-techs-version-of-sports-fans-arguing-over-teams-they-dont-play-for-4jn5</link>
      <guid>https://dev.to/arnoldgunter/framework-wars-are-just-techs-version-of-sports-fans-arguing-over-teams-they-dont-play-for-4jn5</guid>
      <description></description>
      <category>discuss</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>You don't need TypeScript. You need to stop writing code like a maniac. Start there.</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Thu, 08 May 2025 13:40:24 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/you-dont-need-typescript-you-need-to-stop-writing-code-like-a-maniac-start-there-3an5</link>
      <guid>https://dev.to/arnoldgunter/you-dont-need-typescript-you-need-to-stop-writing-code-like-a-maniac-start-there-3an5</guid>
      <description></description>
      <category>softwaredevelopment</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
    <item>
      <title>How The NEW &lt;selectedcontent&gt; HTML Element Changes Selects Forever</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Wed, 07 May 2025 18:44:32 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/how-the-new-html-element-changes-selects-forever-4p7d</link>
      <guid>https://dev.to/arnoldgunter/how-the-new-html-element-changes-selects-forever-4p7d</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hello, fellow web dev&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you’ve ever built a &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; element in HTML, you know the pain: only plain, lifeless text shows up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It’s a UI crime, honestly.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not only does it look awful, but the user experience suffers as well.&lt;/p&gt;

&lt;p&gt;All you see is plain text and with icons or extra styling, users could scan options faster — but that’s not possible.&lt;/p&gt;

&lt;p&gt;And exactly this functionality is what developers have been asking for for decades.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Boom, it’s finally here.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can customize our &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;So let's have a look&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How it works&lt;/li&gt;
&lt;li&gt;How to style it&lt;/li&gt;
&lt;li&gt;Real world examples&lt;/li&gt;
&lt;li&gt;Browser support&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;I go deeper into new HTML features like this in my weekly newsletter. If you liked this post, you shouldn't miss &lt;a href="https://arnold-gunter.kit.com/b33d96a21f?utm_source=devto" rel="noopener noreferrer"&gt;this weeks edition.&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How It Was Before
&lt;/h2&gt;

&lt;p&gt;If you wanted a rich dropdown — icons, HTML, maybe even interactive content — you needed to fake the dropdown using a combination of:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt; for the options,&lt;br&gt;
custom styling,&lt;br&gt;
a little JavaScript to handle opening, closing, and selection.&lt;br&gt;
If you would try to nest HTML code inside the &lt;code&gt;&amp;lt;option&amp;gt;&lt;/code&gt; tag, any browser that seems to render it is either ignoring your inner HTML or treating it as text. You’re stuck with plain text there — no structure, no icons, no nothing.&lt;/p&gt;
&lt;h2&gt;
  
  
  The New Way
&lt;/h2&gt;

&lt;p&gt;Normally a &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;label for="language"&amp;gt;Choose a programming language:&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;select id="language" name="language"&amp;gt;
  &amp;lt;option value="html"&amp;gt;HTML&amp;lt;/option&amp;gt;
  &amp;lt;option value="css"&amp;gt;CSS&amp;lt;/option&amp;gt;
  &amp;lt;option value="javascript"&amp;gt;JavaScript&amp;lt;/option&amp;gt;
  &amp;lt;option value="python"&amp;gt;Python&amp;lt;/option&amp;gt;
  &amp;lt;option value="ruby"&amp;gt;Ruby&amp;lt;/option&amp;gt;
&amp;lt;/select&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have our basic tag with nested options.&lt;/p&gt;

&lt;p&gt;It’s just a standard &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; with some &lt;code&gt;&amp;lt;option&amp;gt;&lt;/code&gt;s—nothing fancy. And when it’s closed, all you see is the plain text label.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So… let’s style this up and not make it look like we are stuck in 1996!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the first step we insert the new &lt;code&gt;&amp;lt;selectedcontent&amp;gt;&lt;/code&gt; just before the first &lt;code&gt;&amp;lt;option&amp;gt;&lt;/code&gt; tag, wrapped in a &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt;. Just like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;label for="language"&amp;gt;Choose a programming language:&amp;lt;/label&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;select id="language" name="language"&amp;gt;
  &amp;lt;button&amp;gt;
    &amp;lt;selectedcontent&amp;gt;&amp;lt;/selectedcontent&amp;gt;
  &amp;lt;/button&amp;gt;
  &amp;lt;option value="html"&amp;gt;HTML&amp;lt;/option&amp;gt;
  &amp;lt;option value="css"&amp;gt;CSS&amp;lt;/option&amp;gt;
  &amp;lt;option value="javascript"&amp;gt;JavaScript&amp;lt;/option&amp;gt;
  &amp;lt;option value="python"&amp;gt;Python&amp;lt;/option&amp;gt;
  &amp;lt;option value="ruby"&amp;gt;Ruby&amp;lt;/option&amp;gt;
&amp;lt;/select&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everytime the selected option changes, HTML creates in the background a clone of the entire HTML inside the &lt;code&gt;&amp;lt;option&amp;gt;&lt;/code&gt; tag via &lt;code&gt;cloneNode()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then it gets displayed in the closed &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Hold up — this won’t work yet. First, we need to unlock the new styling engine...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://medium.com/@arnoldgunter/how-the-new-selectedcontent-html-element-changes-selects-forever-1824abf7b418?sk=9efda86aa767b0bc58003c1c7c56d8e6" rel="noopener noreferrer"&gt;Read the full article here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>tutorial</category>
      <category>html</category>
    </item>
    <item>
      <title>Responsive design is not hiding content on mobile. That’s just bad UX wearing skinny jeans.</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Tue, 22 Apr 2025 15:14:45 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/responsive-design-hiding-content-on-mobile-thats-just-bad-ux-wearing-skinny-jeans-3283</link>
      <guid>https://dev.to/arnoldgunter/responsive-design-hiding-content-on-mobile-thats-just-bad-ux-wearing-skinny-jeans-3283</guid>
      <description></description>
      <category>webdev</category>
      <category>ux</category>
      <category>frontend</category>
      <category>discuss</category>
    </item>
    <item>
      <title>HTML is already a component system. You just hate how simple it is.</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Mon, 21 Apr 2025 14:14:17 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/html-is-already-a-component-system-you-just-hate-how-simple-it-is-2gpo</link>
      <guid>https://dev.to/arnoldgunter/html-is-already-a-component-system-you-just-hate-how-simple-it-is-2gpo</guid>
      <description></description>
      <category>html</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>If your site needs JavaScript to render basic content, you’ve already lost. Fight me.</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Mon, 21 Apr 2025 14:13:01 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/if-your-site-needs-javascript-to-render-basic-content-youve-already-lost-fight-me-1k4n</link>
      <guid>https://dev.to/arnoldgunter/if-your-site-needs-javascript-to-render-basic-content-youve-already-lost-fight-me-1k4n</guid>
      <description></description>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Tailwind is the new jQuery. Overused, misunderstood, and masking deeper CSS issues. Change my mind.</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Sat, 19 Apr 2025 18:27:52 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/tailwind-is-the-new-jquery-overused-misunderstood-and-masking-deeper-css-issues-change-my-mind-1i3h</link>
      <guid>https://dev.to/arnoldgunter/tailwind-is-the-new-jquery-overused-misunderstood-and-masking-deeper-css-issues-change-my-mind-1i3h</guid>
      <description></description>
      <category>tailwindcss</category>
      <category>css</category>
      <category>webdev</category>
      <category>discuss</category>
    </item>
    <item>
      <title>7 JavaScript Interview Questions to Test How Smart You Really Are</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Sat, 19 Apr 2025 15:37:57 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/7-javascript-interview-questions-to-test-how-smart-you-really-are-mi6</link>
      <guid>https://dev.to/arnoldgunter/7-javascript-interview-questions-to-test-how-smart-you-really-are-mi6</guid>
      <description>&lt;p&gt;JavaScript is everywhere. It runs in your browser, your phone apps, maybe even your fridge.&lt;/p&gt;

&lt;p&gt;But do you really understand it? Or are you just copying code from ChatGPT and hoping it works?&lt;/p&gt;

&lt;p&gt;Well… Here are 7 questions interviewers love to ask to find out how smart (or sneaky) you really are.&lt;/p&gt;

&lt;p&gt;Some look easy. Some are traps (the easy ones too). Let’s go!&lt;/p&gt;




&lt;p&gt;👉 Join 200+ web developers already learning smarter HTML, CSS &amp;amp; JavaScript — weekly and free forever.&lt;/p&gt;

&lt;p&gt;Get bite-sized tips, rare tricks, and tools you won’t find in tutorials.&lt;a href="https://arnold-gunter.kit.com/78ce8a5010" rel="noopener noreferrer"&gt; Subscribe to the Weekly Web Dev Digest now.&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Can you count to 10… the JavaScript way?
&lt;/h2&gt;

&lt;p&gt;Interviewers love this one:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Write a function that counts from 1 to 10, logging one number per second.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Easy? Try it.&lt;/p&gt;

&lt;p&gt;Many candidates write a for loop with &lt;code&gt;setTimeout()&lt;/code&gt; inside. Like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (let i = 1; i &amp;lt;= 10; i++) {
  setTimeout(() =&amp;gt; {
    console.log(i);
  }, 1000);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But guess what? That doesn’t work.&lt;/p&gt;

&lt;p&gt;A working solution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (let i = 1; i &amp;lt;= 10; i++) {
  setTimeout(() =&amp;gt; {
    console.log(i);
  }, 1000 * i);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s the deal:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;setTimeout()&lt;/code&gt; doesn’t repeat an action. It waits once, then runs your function.&lt;br&gt;
The second parameter is the delay in milliseconds — how long to wait before running the function.&lt;/p&gt;

&lt;p&gt;So if we just wrote:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;setTimeout(() =&amp;gt; console.log(i), 1000);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It would log all numbers after 1 second, all at once. Why? Because every timeout runs after the same delay.&lt;/p&gt;

&lt;p&gt;But with:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;setTimeout(() =&amp;gt; console.log(i), 1000 * i);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Each i gets its own unique delay:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When i = 1, delay = 1000 * 1 = 1 second&lt;/li&gt;
&lt;li&gt;When i = 2, delay = 1000 * 2 = 2 second&lt;/li&gt;
&lt;li&gt;When i = 10, delay = 1000 * 10 = 10 seconds&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So you’re telling JavaScript:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Hey, log 1 after 1 second, 2 after 2 seconds, ..., 10 after 10 seconds."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Boom — counting!&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Can you handle async like a pro, or just panic?
&lt;/h2&gt;

&lt;p&gt;You’re asked to:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Fetch data from 3 APIs, then do something after they all finish.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This tests if you understand asynchronous code.&lt;/p&gt;

&lt;p&gt;In JavaScript, things like &lt;code&gt;fetch()&lt;/code&gt; or &lt;code&gt;setTimeout()&lt;/code&gt; don’t happen instantly. They start and finish later. If you try to use the result right away, it won’t be there yet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bad approach:&lt;/strong&gt; nested callbacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good approach:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Promise.all([fetchA(), fetchB(), fetchC()])
  .then(([resA, resB, resC]) =&amp;gt; {
    // All done, now do stuff
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Or better:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const data = await Promise.all([fetchA(), fetchB(), fetchC()]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Promise.all()&lt;/code&gt; waits for all promises to finish. Only when everything is done, it gives you the results. No callback hell, no confusion. Just clean and smart.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. What is ‘this’? (No, really.)
&lt;/h2&gt;

&lt;p&gt;this in JavaScript is tricky. It changes depending on how you call a function.&lt;/p&gt;

&lt;p&gt;If you write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const person = {
  name: 'Sam',
  greet() {
    console.log('Hi, I am ' + this.name);
  }
};
person.greet(); // “Hi, I am Sam”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;this&lt;/code&gt; refers to person.&lt;/p&gt;

&lt;p&gt;But if you do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const greet = person.greet;
greet(); // Uh-oh... “Hi, I am undefined”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now &lt;code&gt;this&lt;/code&gt; doesn’t point to person anymore. It points to the global object (or undefined in strict mode).&lt;/p&gt;

&lt;p&gt;Arrow functions are different — they don’t have their own this. They use the this from the place where they were created.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. What are closures, and can you use them without Googling?
&lt;/h2&gt;

&lt;p&gt;Closures are what happen when a function “remembers” variables from the place where it was created.&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 plaintext"&gt;&lt;code&gt;function outer() {
  let count = 0;
  return function inner() {
    count++;
    console.log(count);
  };
}
const counter = outer();
counter(); // 1
counter(); // 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even though &lt;code&gt;outer()&lt;/code&gt; has finished running, &lt;code&gt;inner()&lt;/code&gt; still remembers the count variable. That’s a closure. It lets functions keep state. Super useful for things like counters, timers, or private variables.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Do you even ‘bind’, bro?
&lt;/h2&gt;

&lt;p&gt;Here’s the deal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;doThis('foo', something.doThat);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This passes a reference to &lt;code&gt;doThat&lt;/code&gt;. But:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;doThis('foo', () =&amp;gt; something.doThat());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This calls &lt;code&gt;doThat()&lt;/code&gt; right away and passes the result.&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;doThat&lt;/code&gt; depends on this, passing it directly might break it. That’s where &lt;code&gt;.bind()&lt;/code&gt; helps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;doThis('foo', something.doThat.bind(something));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the function will always use the correct this.&lt;/p&gt;

&lt;p&gt;Knowing when to pass a function vs. call it, and how this behaves, is key to writing clean, working code. If you pass a function and it loses its context, weird bugs show up.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Is a function a first-class citizen?
&lt;/h2&gt;

&lt;p&gt;In JavaScript:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can put a function in a variable.&lt;/li&gt;
&lt;li&gt;You can pass it to another function.&lt;/li&gt;
&lt;li&gt;You can return it from a function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s what first-class means.&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 plaintext"&gt;&lt;code&gt;function greet(name) {
  return 'Hello ' + name;
}

function welcome(fn) {
  console.log(fn('Alice'));
}
welcome(greet); // Hello Alice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why it works:&lt;br&gt;
JavaScript treats functions like any other value. This lets you build higher-order functions, callbacks, and more powerful patterns.&lt;/p&gt;
&lt;h2&gt;
  
  
  7. Can you explain prototypal inheritance without sweating?
&lt;/h2&gt;

&lt;p&gt;JavaScript doesn’t use class-based inheritance like Java or C++.&lt;/p&gt;

&lt;p&gt;It uses prototypes.&lt;/p&gt;

&lt;p&gt;Every object can point to another object — its prototype. When you try to access a property that doesn’t exist, JavaScript looks up the prototype chain.&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 plaintext"&gt;&lt;code&gt;const animal = {
  speak() {
    console.log('Animal sound');
  }
};

const dog = Object.create(animal);
dog.speak(); // Animal sound
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why it works:&lt;br&gt;
&lt;code&gt;dog&lt;/code&gt; doesn’t have a &lt;code&gt;speak()&lt;/code&gt; method. But its prototype (animal) does. JavaScript finds it up the chain and uses it. This is how inheritance works under the hood.&lt;/p&gt;

&lt;p&gt;Final Thoughts&lt;br&gt;
JavaScript is a fun language, but it’s full of little traps. If you can answer these questions without copying from ChatGPT (wait a minute…), you’re well on your way to JavaScript mastery.&lt;/p&gt;

&lt;p&gt;Just remember: knowing what works is good. Knowing why it works is even better.&lt;/p&gt;

&lt;p&gt;Good luck!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>interview</category>
    </item>
    <item>
      <title>5 HTML Tricks to WOW Your Users</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Wed, 09 Apr 2025 15:25:07 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/5-html-tricks-to-wow-your-users-30pe</link>
      <guid>https://dev.to/arnoldgunter/5-html-tricks-to-wow-your-users-30pe</guid>
      <description>&lt;p&gt;We all want to create that website that stands out, right? With that great buttery smooth user experience! Right?&lt;/p&gt;

&lt;p&gt;Well, let me help you with 5 HTML tricks you never knew existed!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://arnold-gunter.kit.com/78ce8a5010" rel="noopener noreferrer"&gt;— Join hundreds of web developers leveling up their skills with my weekly newsletter — it is FREE —&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Use the Camera on Mobile Devices
&lt;/h2&gt;

&lt;p&gt;Did you know you can let users take pictures directly from your website? No need for third-party apps or special permissions — just a simple HTML attribute.&lt;br&gt;
&lt;strong&gt;How It Works&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Camera Capture&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        body { text-align: center; font-family: Arial, sans-serif; padding: 20px; }
        input { margin-top: 20px; padding: 10px; }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h2&amp;gt;Say Cheese! 📸&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;Click below to take a photo using your camera. (Only on mobile devices)&amp;lt;/p&amp;gt;
    &amp;lt;input type="file" accept="image/*" capture="environment"&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;&amp;lt;input type="file"&amp;gt;&lt;/code&gt; element allows users to upload files.&lt;/li&gt;
&lt;li&gt;Adding &lt;code&gt;capture="environment"&lt;/code&gt; tells the browser to use the back camera.&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;capture="user"&lt;/code&gt; opens the front camera instead.
This is great for profile pictures, document uploads, or even just taking quick snapshots.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Add a Built-in Color Picker
&lt;/h2&gt;

&lt;p&gt;Instead of making users type out hex codes, why not let them choose a color with a simple, built-in tool?&lt;br&gt;
&lt;strong&gt;How It Works&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Color Picker&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        body { text-align: center; font-family: Arial, sans-serif; padding: 20px; }
        input { margin-top: 20px; padding: 10px; }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h2&amp;gt;Pick a Color! 🎨&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;Select your favorite color below:&amp;lt;/p&amp;gt;
    &amp;lt;input type="color"&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;&amp;lt;input type="color"&amp;gt;&lt;/code&gt; element opens a color picker when clicked.&lt;/li&gt;
&lt;li&gt;Users can select a color, and the browser returns the hex code (like #ff5733).
This is perfect for themes, design customization, or any feature that requires color selection.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Block Right-Clicking
&lt;/h2&gt;

&lt;p&gt;If you want to prevent people from easily copying your content or saving images, you can disable right-clicking with a simple trick.&lt;br&gt;
&lt;strong&gt;How It Works&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body oncontextmenu="return false"&amp;gt;
    &amp;lt;h2&amp;gt;Try Right-Clicking! 😏&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;Oops! It’s disabled!&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It won’t stop determined users, but it adds a small layer of protection against casual content theft.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Let Users Talk Instead of Type
&lt;/h2&gt;

&lt;p&gt;Typing can be slow, so why not let users speak instead? With a single attribute, you can enable voice input in your forms.&lt;br&gt;
&lt;strong&gt;How It Works&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Voice Input&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        body { text-align: center; font-family: Arial, sans-serif; padding: 20px; }
        input { padding: 10px; width: 80%; }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h2&amp;gt;Talk to Me! 🎤&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;Click the mic icon and start speaking.&amp;lt;/p&amp;gt;
    &amp;lt;input type="text" x-webkit-speech&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Adding &lt;code&gt;x-webkit-speech&lt;/code&gt; to an &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; field enables speech-to-text in Chrome on mobile devices.&lt;/li&gt;
&lt;li&gt;A microphone icon appears inside the input box.&lt;/li&gt;
&lt;li&gt;Users click it, speak, and the text appears automatically.
This is especially useful for search bars, chat applications, or accessibility features.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Refresh or Redirect a Page Automatically
&lt;/h2&gt;

&lt;p&gt;Sometimes, you want a page to refresh itself or redirect users after a few seconds. You don’t need JavaScript for this — just a simple meta tag.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Works&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;meta http-equiv="refresh" content="5"&amp;gt; refreshes the page every 5 seconds.
&amp;lt;meta http-equiv="refresh" content="5; url=https://example.com"&amp;gt; redirects after 5 seconds. This is useful for live updates, countdown pages, or guiding users to the right content.
&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Auto Refresh &amp;amp; Redirect&amp;lt;/title&amp;gt;
    &amp;lt;meta http-equiv="refresh" content="5; url=https://example.com"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h2&amp;gt;Hold Tight! ⏳&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;You will be redirected in 5 seconds...&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
These small HTML tricks can improve your website’s user experience with minimal effort. They work across most browsers and don’t require any extra libraries or scripts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try them out, and happy coding!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>html</category>
    </item>
    <item>
      <title>If You Can Answer These 7 Questions Correctly You’re Decent at JavaScript</title>
      <dc:creator>Arnold Gunter</dc:creator>
      <pubDate>Mon, 07 Apr 2025 14:45:58 +0000</pubDate>
      <link>https://dev.to/arnoldgunter/if-you-can-answer-these-7-questions-correctly-youre-decent-at-javascript-7dc</link>
      <guid>https://dev.to/arnoldgunter/if-you-can-answer-these-7-questions-correctly-youre-decent-at-javascript-7dc</guid>
      <description>&lt;p&gt;This article was originally published &lt;a href="https://medium.com/p/71e0ce9d7ac9" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;JavaScript can be a little tricky sometimes, even when you’re dealing with simple-looking problems.&lt;/p&gt;

&lt;p&gt;Here are seven questions that test different parts of JavaScript.&lt;/p&gt;

&lt;p&gt;They look easy, but they can catch you off guard! If you can answer these, you’ve got a good handle on JavaScript!&lt;/p&gt;




&lt;p&gt;&lt;a href="https://arnold-gunter.kit.com/78ce8a5010" rel="noopener noreferrer"&gt;JOIN MY FREE WEEKLY WEBDEV NEWSLETTER!&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 1: What’s the Result of 0.1 + 0.2 === 0.3?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(0.1 + 0.2 === 0.3);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
The result is false.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
In JavaScript, numbers with decimals (called floating-point numbers) don’t always add up the way we expect.&lt;/p&gt;

&lt;p&gt;Due to how floating-point numbers are represented in JavaScript, 0.1 + 0.2 doesn’t exactly equal 0.3. Instead, it results in 0.30000000000000004, leading to the comparison being false. This issue comes from the binary approximation of decimal numbers in JavaScript.&lt;/p&gt;


&lt;h3&gt;
  
  
  Question 2: What’s the Result of "5" + 3 and "5" - 3?
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log("5" + 3);
console.log("5" - 3);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
"5" + 3 results in "53".&lt;br&gt;
"5" - 3 results in 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
"5" + 3: When you use the + sign with a string and a number, JavaScript treats the number like a part of the string. So instead of adding 5 and 3 as numbers, it sticks them together as text, resulting in "53".&lt;/p&gt;

&lt;p&gt;"5" - 3: The - operator doesn’t work with strings, so JavaScript converts "5" to a number and subtracts 3, resulting in 2.&lt;/p&gt;


&lt;h3&gt;
  
  
  Question 3: What’s the Value of typeof null?
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(typeof null);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
The result is "object".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
This is a weird part of JavaScript. The typeof operator should tell you what kind of value you have.&lt;/p&gt;

&lt;p&gt;But when you check typeof null, JavaScript mistakenly says it’s an object, even though null is actually a special value that means "nothing."&lt;/p&gt;

&lt;p&gt;This is a bug that has been around for a long time and hasn’t been changed to keep old code from breaking.&lt;/p&gt;


&lt;h3&gt;
  
  
  Question 4: How Does a Closure Work?
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function outerFunction() {
  let count = 0;
  return function() {
    count++;
    console.log(count);
  };
}

const closure = outerFunction();
closure(); // ?
closure(); // ?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
The output will be:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
A closure happens when a function remembers the variables around it, even after the outer function has finished running.&lt;/p&gt;

&lt;p&gt;In this example, the inner function still has access to the count variable inside outerFunction. Each time you call closure(), it increases count and shows it.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 5: What’s the Result of true + false and [] + {}?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(true + false);
console.log([] + {});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
true + false gives 1.&lt;br&gt;
[] + {} gives "[object Object]".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
true + false: In JavaScript, true is treated as 1 and false as 0. Adding 1 + 0 gives 1.&lt;/p&gt;

&lt;p&gt;[] + {}: When you add an empty array [] to an empty object {}, JavaScript changes them to strings. The empty array becomes an empty string "", and the empty object becomes "[object Object]". So, adding them gives "[object Object]".&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 6: What Does [] == ![] Mean?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log([] == ![]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
The result is true.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
This is tricky! Here’s what happens:&lt;/p&gt;

&lt;p&gt;![] means "not an empty array." An empty array is a "truthy" value, so ![] is false.&lt;br&gt;
Now, the expression is [] == false.&lt;br&gt;
JavaScript tries to compare [] and false. It changes [] into an empty string "" and false into 0.&lt;br&gt;
Then, "" == 0 is true because JavaScript changes the empty string to 0 when comparing.&lt;/p&gt;




&lt;h3&gt;
  
  
  Question 7: What’s the Output of console.log(a) in the Following Code?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(a);
var a = 5;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;br&gt;
The output is undefined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
This happens because of something called hoisting. When JavaScript reads your code, it moves all variable declarations to the top of their scope.&lt;/p&gt;

&lt;p&gt;So, in this case, JavaScript sees var a; at the top, but the value 5 hasn’t been assigned yet. So when you try to log a, it’s declared but still undefined.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;How did you do?&lt;br&gt;
These questions mix JavaScript’s odd behavior with some important concepts like closures and hoisting.&lt;/p&gt;

&lt;p&gt;Knowing these will help you avoid common mistakes and better understand how JavaScript handles different operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy coding!&lt;/strong&gt;&lt;/p&gt;

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