<?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: Yash Chavan</title>
    <description>The latest articles on DEV Community by Yash Chavan (@hunt092).</description>
    <link>https://dev.to/hunt092</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%2F1012825%2F90f1e6d2-9f55-41dc-8499-bfc8569826e6.jpg</url>
      <title>DEV Community: Yash Chavan</title>
      <link>https://dev.to/hunt092</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hunt092"/>
    <language>en</language>
    <item>
      <title>Git is Not Magic- Part 2: Where Are You in the Timeline?</title>
      <dc:creator>Yash Chavan</dc:creator>
      <pubDate>Sat, 07 Feb 2026 13:20:35 +0000</pubDate>
      <link>https://dev.to/hunt092/git-is-not-magic-part-2-where-are-you-in-the-timeline-4ifn</link>
      <guid>https://dev.to/hunt092/git-is-not-magic-part-2-where-are-you-in-the-timeline-4ifn</guid>
      <description>&lt;p&gt;Remember that question from &lt;a href="https://hashnode.com/post/cmkupxwh4000202jrf0mv8267" rel="noopener noreferrer"&gt;Part 1&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;"&lt;em&gt;Where exactly are YOU in this timeline?&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;Let's answer it.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Pointer Called HEAD&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now that we know our commits form a linked list pointing backward through time, there's one crucial piece missing: &lt;strong&gt;&lt;em&gt;where are we right now?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Think back to our Polaroid album. You've got all these photos laid out, but you need to know which photo represents "&lt;em&gt;now&lt;/em&gt;", which step of the cake you're currently working on. &lt;em&gt;Are you still layering cream&lt;/em&gt;? Or &lt;em&gt;have you moved on to adding decorations&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;In Git, this "&lt;strong&gt;&lt;em&gt;you are here&lt;/em&gt;&lt;/strong&gt;" marker is called &lt;strong&gt;HEAD&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;HEAD is just a pointer. That's it. It points to whichever commit you're currently looking at. Most of the time, it points to your latest commit, the present moment in your project's timeline.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;commit 0 &amp;lt;- commit 1 &amp;lt;- commit 2 &amp;lt;- commit 3
                                      ↑
                                     HEAD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you make a new commit, HEAD moves forward with you:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;commit 0 &amp;lt;- commit 1 &amp;lt;- commit 2 &amp;lt;- commit 3 &amp;lt;- commit 4
                                                  ↑
                                                 HEAD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But here's where it gets interesting: HEAD can move &lt;em&gt;backward&lt;/em&gt; too.&lt;/p&gt;

&lt;p&gt;You can literally tell Git &lt;em&gt;"take me back to commit 2"&lt;/em&gt; and suddenly you're looking at your code exactly as it was back then. It's like picking up an old Polaroid from your album and saying "&lt;em&gt;I want to see what the cake looked like at this stage.&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;This is what &lt;code&gt;git checkout&lt;/code&gt; does it moves HEAD to wherever you tell it to go.&lt;/p&gt;

&lt;p&gt;Now here's where HEAD becomes really interesting: it doesn't just point to commits. Most of the time, HEAD points to a &lt;em&gt;branch&lt;/em&gt;, and the branch points to a commit. When you make a new commit, the branch moves forward, and HEAD moves with it.&lt;/p&gt;

&lt;p&gt;Keep this in mind as we talk about branches next.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Branches: Multiple Timelines&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now let's make things spicy.&lt;/p&gt;

&lt;p&gt;What if while making your 3-layered cake, you had a sudden idea: "&lt;em&gt;What if I made a chocolate version too?&lt;/em&gt;" You don't want to mess up your original vanilla cake, but you want to try this new idea.&lt;/p&gt;

&lt;p&gt;So you take a Polaroid of where you are now, and start a &lt;strong&gt;&lt;em&gt;separate&lt;/em&gt;&lt;/strong&gt; album for the chocolate version. Both cakes start from the same point, but now they evolve differently.&lt;/p&gt;

&lt;p&gt;This is what &lt;strong&gt;branches&lt;/strong&gt; are.&lt;/p&gt;

&lt;p&gt;A branch is just a label that points to a commit. That's literally all it is. And when you create a new branch, you're creating a new timeline that splits off from the current one.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;                    ← commit 4 (chocolate-version)
                   /
commit 0 &amp;lt;- commit 1 &amp;lt;- commit 2 &amp;lt;- commit 3 (main)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can work on &lt;code&gt;chocolate-version&lt;/code&gt;, make commits, mess things up, experiment freely - and your &lt;code&gt;main&lt;/code&gt; branch stays untouched. Your original vanilla cake is safe.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Merging: Bringing Timelines Together&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;After experimenting, you realize the chocolate version turned out amazing. You want to bring those changes back into your main cake recipe.&lt;/p&gt;

&lt;p&gt;This is called &lt;strong&gt;merging&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When you merge, you're telling Git: "&lt;em&gt;Take everything that happened in this alternate timeline and combine it with my current timeline.&lt;/em&gt;"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;commit 0 &amp;lt;- commit 1 &amp;lt;- commit 2 &amp;lt;- commit 3 &amp;lt;- commit 5 (merge commit)
                   &lt;span class="se"&gt;\ &lt;/span&gt;                          /
                    ← commit 4 (chocolate-version)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Git creates a special &lt;strong&gt;merge commit&lt;/strong&gt; that has &lt;em&gt;two parents&lt;/em&gt; one from each timeline. It's like saying "this point in history came from both paths."&lt;/p&gt;

&lt;p&gt;Most of the time, Git is smart enough to figure out how to combine changes automatically. But sometimes there are &lt;strong&gt;merge conflicts&lt;/strong&gt; situations where Git can't decide which change to keep. This happens when both timelines modified the same part of the same file differently.&lt;/p&gt;

&lt;p&gt;It's like if in your chocolate timeline you added dark chocolate frosting, but in your main timeline you already added vanilla frosting to the same layer. Git stops and asks: "Which one do you want?"&lt;/p&gt;

&lt;p&gt;You have to manually resolve the conflict pick one, combine them, or do something else entirely. Then you tell Git "okay, I've decided" and complete the merge.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Rebasing: Rewriting History&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;But what if you don't want that messy merge commit? What if you want your timeline to look clean, like the chocolate experiment happened &lt;em&gt;after&lt;/em&gt; the main branch, not alongside it?&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;rebase&lt;/strong&gt; comes in.&lt;/p&gt;

&lt;p&gt;Rebasing is like saying: "&lt;em&gt;Take all my experimental commits, and pretend they started from a different point in time&lt;/em&gt;."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Before rebase:
                    ← commit 4 (chocolate-version)
                   /
commit 0 &amp;lt;- commit 1 &amp;lt;- commit 2 &amp;lt;- commit 3 (main)

After rebase:
commit 0 &amp;lt;- commit 1 &amp;lt;- commit 2 &amp;lt;- commit 3 &amp;lt;- commit 4' (chocolate-version)
                                     (main)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice commit 4 became commit 4', it's technically a &lt;em&gt;new&lt;/em&gt; commit with the same changes but a different starting point. You've rewritten history.&lt;/p&gt;

&lt;p&gt;Rebasing makes your history linear and clean. But here's the golden rule: &lt;strong&gt;never rebase commits that you've already shared with others&lt;/strong&gt; [yes a rule to memorize]. Because you're literally changing history, and if someone else was working off the old history, you'll create a mess.&lt;/p&gt;

&lt;p&gt;Think of it like this: merging is honest (it shows both timelines happened), rebasing is tidy (it pretends only one timeline happened).&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;You've Got the Power Now&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let's recap:&lt;/p&gt;

&lt;p&gt;HEAD is just a pointer showing where you are. Branches are just labels, letting you create parallel universes for your code. Merging brings timelines together honestly. Rebasing rewrites history to keep things tidy.&lt;/p&gt;

&lt;p&gt;You're not just taking Polaroids anymore, you're organizing entire photo albums, creating alternate storylines, and deciding how they come together.&lt;/p&gt;

&lt;p&gt;But here's the thing:&lt;/p&gt;

&lt;p&gt;So far, this has all been happening on &lt;em&gt;your&lt;/em&gt; machine. Your Polaroids. Your albums. Your timelines.&lt;/p&gt;

&lt;p&gt;What happens when you want to share these with your team? When you and a teammate both have photo albums of the same project?&lt;/p&gt;

&lt;p&gt;How do you keep them in sync?&lt;/p&gt;

&lt;p&gt;How does "your timeline" become "our timeline"?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;That's Part 3.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Git Is Not Magic: Part 1: The Polaroid Analogy</title>
      <dc:creator>Yash Chavan</dc:creator>
      <pubDate>Mon, 26 Jan 2026 07:31:41 +0000</pubDate>
      <link>https://dev.to/hunt092/git-is-not-magic-part-1-the-polaroid-analogy-2b0f</link>
      <guid>https://dev.to/hunt092/git-is-not-magic-part-1-the-polaroid-analogy-2b0f</guid>
      <description>&lt;p&gt;Git is something each one of us in today’s world has to learn and well for most, it’s memorizing the command and using them like a type of flow:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;add → commit → pull → push&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;…without understanding what Git actually is, or how it works, which keeps most of us scared of doing anything with Git.&lt;/p&gt;

&lt;p&gt;IT DOESNT HAVE TO BE THAT WAY.&lt;/p&gt;

&lt;p&gt;Let go on a very simple journey to understand Git, and get you from “Git scared” to “Git confident”, starting from the crux of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Git?
&lt;/h2&gt;

&lt;p&gt;The technical definition of Git is:&lt;/p&gt;

&lt;p&gt;“&lt;a href="https://git-scm.com/" rel="noopener noreferrer"&gt;Git is a distributed version control software system&lt;/a&gt;”&lt;/p&gt;

&lt;p&gt;But that’s very vague &lt;em&gt;WHAT DOES IT EVEN MEAN!?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So lets take a step back and understand the technicalities ,&lt;/p&gt;

&lt;p&gt;Git as we all know, keep track of our files, and the changes we make to them hence &lt;strong&gt;&lt;em&gt;version control system&lt;/em&gt;&lt;/strong&gt;,&lt;br&gt;&lt;br&gt;
&lt;em&gt;But then what the&lt;/em&gt; “&lt;strong&gt;&lt;em&gt;distributed”&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;part is? ,&lt;/em&gt;&lt;br&gt;&lt;br&gt;
That means you don’t just have the latest code, you have the &lt;em&gt;entire&lt;/em&gt; &lt;strong&gt;&lt;em&gt;history&lt;/em&gt;&lt;/strong&gt; on your own machine.&lt;br&gt;&lt;br&gt;
When you use GitHub, GitLab, or Bitbucket, you’re just syncing your copy of history with someone else’s copy of history.&lt;/p&gt;

&lt;p&gt;You are not “sending code to a server”.&lt;br&gt;&lt;br&gt;
You are syncing timelines.&lt;/p&gt;

&lt;p&gt;(And fun fact: it doesn’t even have to be GitHub — but that’s a story for another blog.)&lt;/p&gt;

&lt;p&gt;Still feels a bit technical, right?&lt;br&gt;&lt;br&gt;
So let’s make it visual.&lt;/p&gt;
&lt;h2&gt;
  
  
  Taking Polaroids
&lt;/h2&gt;

&lt;p&gt;Imagine we are baking a 3 layered cake, and you want to keep track of each step of the cake.&lt;/p&gt;

&lt;p&gt;Every time we finish a step we pull out our Polaroid and click a photo, starting with setting the first base,*click* cutting it as we want,*click* layering it with basic cream, and so forth till we finish the entire cake&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3gm9mpksqv767z950e1u.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3gm9mpksqv767z950e1u.jpg" alt="Polaroid photo of cake stringed together with thread" width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With each click, we are seeing the cake getting created out of nothing and we create a timeline for the cake creation.&lt;/p&gt;

&lt;p&gt;This is what Git is like, where each photo is the &lt;code&gt;commit&lt;/code&gt; we do, and just like the cake following our &lt;code&gt;commits&lt;/code&gt; tells us the story of how we created our project from nothing.&lt;/p&gt;
&lt;h2&gt;
  
  
  Committing History
&lt;/h2&gt;

&lt;p&gt;With every &lt;code&gt;commit&lt;/code&gt; we do, we are creating the history of our project [ yes the same one we talked about during the distributed part ] and like the threads of the Polaroid, we can follow this history to find the origin.&lt;br&gt;&lt;br&gt;
Now in our tech world this is now it would look like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;commit 0 &amp;lt;- commit 1 &amp;lt;- commit 2 &amp;lt;- present
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Doesn’t this look familiar …. that’s right its a linked list, just reversed,&lt;br&gt;&lt;br&gt;
So every commit is like a node, and the arrow is the “next” pointer - except it points to the past and each node holds the snapshot of your code at that point of time.&lt;/p&gt;

&lt;p&gt;So your Polaroid album is secretly a linked list.&lt;/p&gt;

&lt;p&gt;You don’t need to think of Git like this all the time, but knowing this once removes a lot of fear.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;You're Not Scared Anymore, Are You?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let's recap what we've learned:&lt;/p&gt;

&lt;p&gt;Git isn't magic. It's just Polaroids. Each commit is a snapshot of your project at a moment in time, and these snapshots form a linked list pointing backward through history. That's it.&lt;/p&gt;

&lt;p&gt;When you do &lt;code&gt;git add&lt;/code&gt; and &lt;code&gt;git commit&lt;/code&gt;, you're not performing some mystical ritual — you're just taking a photo and adding it to your timeline.&lt;/p&gt;

&lt;p&gt;The "distributed" part? That just means everyone has their own complete photo album, their own copy of the entire history. You're not dependent on some server in the cloud. You &lt;em&gt;are&lt;/em&gt; the source of truth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But wait.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If commits are snapshots in time, and they form this chain going backward through history...&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Where exactly are YOU in this timeline?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Think about it. You've got this entire chain of commits stretching back to the beginning. But right now, as you're working on your code — which snapshot are you standing on?&lt;/p&gt;

&lt;p&gt;And here's the real question: &lt;strong&gt;Can you move?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next time you make a commit, don't think of it as "saving to Git." Think of it as "clicking a Polaroid."&lt;/p&gt;

&lt;p&gt;You're building a timeline. You're creating history.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But who's holding the camera?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;[Part 2 coming soon]&lt;/em&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>learning</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Great OOP Illusion in JS</title>
      <dc:creator>Yash Chavan</dc:creator>
      <pubDate>Mon, 15 Sep 2025 03:50:09 +0000</pubDate>
      <link>https://dev.to/hunt092/the-great-oop-illusion-in-js-1j8j</link>
      <guid>https://dev.to/hunt092/the-great-oop-illusion-in-js-1j8j</guid>
      <description>&lt;p&gt;OOP is probably one of the first things we learn as programmers — in school, from tutorials, or when brushing up for that promotion and diving into design patterns. We’re taught about classes as blueprints, and objects as their instances. It feels universal: Java, C++, Python… OOP everywhere.&lt;/p&gt;

&lt;p&gt;So naturally, when we start writing JS, we expect the same rules to apply. Classes, objects, inheritance — the works.  &lt;/p&gt;

&lt;p&gt;But here’s the twist: &lt;strong&gt;JavaScript fakes OOP&lt;/strong&gt; really well — but under the hood, it’s something very different.&lt;/p&gt;

&lt;p&gt;Let’s peel back that facade and see the truth of OOP in JS, using the very common example of a &lt;strong&gt;Human&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Example Problem
&lt;/h2&gt;

&lt;p&gt;Usually when OOP is taught, we pick a real-life analogy to make sense of it. So let’s do the same here.&lt;/p&gt;

&lt;p&gt;We want to represent a &lt;strong&gt;Human&lt;/strong&gt;. A Human has a &lt;code&gt;name&lt;/code&gt;, an &lt;code&gt;age&lt;/code&gt;, can &lt;code&gt;greet()&lt;/code&gt; others and also grows old celebrating with &lt;code&gt;happyBirthday()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But here’s the catch: let’s &lt;em&gt;forget OOP exists&lt;/em&gt; for a moment. How would we build this the JavaScript way?&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Human
&lt;/h2&gt;

&lt;p&gt;Lets keep it stupid simple, and just create a Human.&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;let&lt;/span&gt; &lt;span class="nx"&gt;human1&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;Adam&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;function &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="s2"&gt;`Hi, I’m &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&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="k"&gt;this&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="s2"&gt; years old.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;happyBirthday&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&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="s2"&gt;`It’s my birthday! I’m now &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&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="s2"&gt;.`&lt;/span&gt;&lt;span class="p"&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;human1&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="c1"&gt;// Hi, I’m Adam, 25 years old.&lt;/span&gt;
&lt;span class="nx"&gt;human1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;happyBirthday&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="c1"&gt;// It’s my birthday! I’m now 26.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it we have created our Human, but this gives us only one Human. If we want more, we’d have to copy-paste this whole object. Too much effort, so lets reduce this and make a &lt;code&gt;Human Factory&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Factory Pattern
&lt;/h2&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;createHuman&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="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&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="na"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;function &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="s2"&gt;`Hi, I’m &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&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="k"&gt;this&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="s2"&gt; years old.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;happyBirthday&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&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="s2"&gt;`It’s my birthday! I’m now &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&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="s2"&gt;.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&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;human1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createHuman&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Bob&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;human1&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="c1"&gt;// Hi, I’m Bob, 30 years old.&lt;/span&gt;
&lt;span class="nx"&gt;human1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;happyBirthday&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;    &lt;span class="c1"&gt;// It’s my birthday! I’m now 31.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;dusts hands off&lt;/em&gt; — now I can create as many Humans as I like. Pretty neat.&lt;/p&gt;

&lt;p&gt;But wait… problem spotted! Every Human gets its &lt;strong&gt;own copy&lt;/strong&gt; of &lt;code&gt;greet&lt;/code&gt; and &lt;code&gt;happyBirthday&lt;/code&gt;. If I make 1,000 Humans, that’s 1,000 duplicate functions sitting in memory. Yikes.&lt;/p&gt;

&lt;p&gt;Surely JavaScript has some secret sauce for this.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Secret Sauce Revealed
&lt;/h2&gt;

&lt;p&gt;Turns out JS does has a Secret sauce, instead of cloning methods for every object, JavaScript quietly gives each object a &lt;strong&gt;hidden backstage link&lt;/strong&gt;. Through this link, objects can borrow methods from a shared place — no duplication needed.&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;humanMethods&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;function &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="s2"&gt;`Hi, I’m &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&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="k"&gt;this&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="s2"&gt; years old.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;happyBirthday&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&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="s2"&gt;`It’s my birthday! I’m now &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&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="s2"&gt;.`&lt;/span&gt;&lt;span class="p"&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;function&lt;/span&gt; &lt;span class="nf"&gt;createHuman&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="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;human&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;humanMethods&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// &amp;lt;-- the hidden link&lt;/span&gt;
  &lt;span class="nx"&gt;human&lt;/span&gt;&lt;span class="p"&gt;.&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;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;human&lt;/span&gt;&lt;span class="p"&gt;.&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;age&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;human&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;h1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createHuman&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Charlie&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;h1&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="c1"&gt;// Hi, I’m Charlie, 22 years old.&lt;/span&gt;
&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;happyBirthday&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;    &lt;span class="c1"&gt;// It’s my birthday! I’m now 23.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This hidden link is nothing but a hidden property called &lt;code&gt;__proto__&lt;/code&gt;, which every JavaScript object has.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;👉And remember, in JavaScript everything is an object (well… except a few primitives, but even they behave like objects when needed. And no — not class instance objects, just plain JS objects).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When JS runs and can’t find a property directly on your object, it doesn’t panic. Instead, it follows this hidden &lt;code&gt;__proto__&lt;/code&gt; trail, looking for the property in the linked object. That’s how &lt;code&gt;greet&lt;/code&gt; and &lt;code&gt;happyBirthday&lt;/code&gt; magically work without being duplicated.&lt;/p&gt;

&lt;p&gt;Pretty neat, right?&lt;/p&gt;

&lt;h2&gt;
  
  
  Walks in the &lt;code&gt;new&lt;/code&gt; Approach
&lt;/h2&gt;

&lt;p&gt;But wiring up these hidden links with &lt;code&gt;Object.create&lt;/code&gt; still feels a bit manual. Wouldn’t it be nice if JavaScript gave us a cleaner way to do it?&lt;/p&gt;

&lt;p&gt;Turns out, functions themselves carry a secret power: they’re objects too, and each one has its own “backstage” property called &lt;code&gt;prototype&lt;/code&gt;. And when you combine that with the &lt;code&gt;new&lt;/code&gt; keyword… boom, you get a much cleaner way to wire things up.&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;Human&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="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&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;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&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;age&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;Human&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &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="s2"&gt;`Hi, I’m &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&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="k"&gt;this&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="s2"&gt; years old.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;Human&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;happyBirthday&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&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="s2"&gt;`It’s my birthday! I’m now &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&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="s2"&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;h1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Human&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dave&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;h1&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="c1"&gt;// Hi, I’m Dave, 40 years old.&lt;/span&gt;
&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;happyBirthday&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;    &lt;span class="c1"&gt;// It’s my birthday! I’m now 41.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Much cleaner! Now the “hidden link” is managed automatically by &lt;code&gt;new&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;*👉 Curious about how this hidden link (aka prototypes) really work under the hood?&lt;br&gt;&lt;br&gt;
💬 Drop a comment below if you’d like me to write a full breakdown of prototypes in my next blog.  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; 
Feels like a class, right? But don’t be fooled. &lt;code&gt;Human&lt;/code&gt; is just a function, and &lt;code&gt;new Human()&lt;/code&gt; creates a plain JS object linked to &lt;code&gt;Human.prototype&lt;/code&gt;. Still no real classes yet.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The Final Facade - Classes
&lt;/h2&gt;

&lt;p&gt;So far, we’ve gone from copy-pasting objects → factory functions → constructor functions with prototypes. Each step got us closer to something that &lt;em&gt;looked&lt;/em&gt; like OOP, while still being powered by JavaScript’s hidden prototype magic.&lt;/p&gt;

&lt;p&gt;And then ES6 came along and said:&lt;br&gt;&lt;br&gt;
“Hey devs, I see you’re faking classes anyway… why not make it look familiar?”&lt;/p&gt;

&lt;p&gt;Enter &lt;code&gt;class&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Human&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&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="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&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;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&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;age&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="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="s2"&gt;`Hi, I’m &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&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="k"&gt;this&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="s2"&gt; years old.`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;happyBirthday&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="o"&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="s2"&gt;`It’s my birthday! I’m now &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&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="s2"&gt;.`&lt;/span&gt;&lt;span class="p"&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;h1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Human&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Eve&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;h1&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="c1"&gt;// Hi, I’m Eve, 28 years old.&lt;/span&gt;
&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;happyBirthday&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;   &lt;span class="c1"&gt;// It’s my birthday! I’m now 29.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it really looks like OOP. The same familiar feeling like with JAVA, C++, Python…&lt;/p&gt;

&lt;p&gt;But here’s the kicker:&lt;br&gt;&lt;br&gt;
👉 &lt;code&gt;class&lt;/code&gt; in JavaScript doesn’t invent a new OOP system. It’s pure &lt;strong&gt;syntactic sugar&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Behind the curtain, that &lt;code&gt;class Human&lt;/code&gt; is still just a &lt;em&gt;constructor function.&lt;/em&gt; Its methods? Still attached to &lt;code&gt;Human.prototype&lt;/code&gt;. The “hidden link” we talked about? Still doing the heavy lifting.&lt;/p&gt;

&lt;p&gt;The only real difference is how nice it looks when you type it.&lt;/p&gt;

&lt;p&gt;So yeah, JS gives us the full OOP costume — but don’t be fooled. The foundation is still prototypes, all the way down.&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;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="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;Human&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// function&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Today, with GenAI and agentic tools writing much of our code, it’s tempting to skip fundamentals. But when things break — or when something new comes up — understanding what’s really happening under the hood is the difference between struggling and thriving as a developer.&lt;/p&gt;

&lt;p&gt;JavaScript’s OOP is a perfect example. It looks familiar, but it’s fundamentally different. Once you see past the illusion, you gain a deeper mastery of the language, and that’s what truly makes you a better engineer.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Demystifying Next.js: A Fresh Perspective on the Meta-Framework Enhancing React.js</title>
      <dc:creator>Yash Chavan</dc:creator>
      <pubDate>Thu, 24 Aug 2023 13:35:30 +0000</pubDate>
      <link>https://dev.to/hunt092/demystifying-nextjs-a-fresh-perspective-on-the-meta-framework-enhancing-reactjs-3f0j</link>
      <guid>https://dev.to/hunt092/demystifying-nextjs-a-fresh-perspective-on-the-meta-framework-enhancing-reactjs-3f0j</guid>
      <description>&lt;p&gt;Embarking on the journey of web development, I was naturally drawn to the booming world of Next.js. A framework that purportedly makes React.js even better – an enticing prospect. However, unlike my relatively smooth experience with web and React.js, Next.js initially proved to be a challenge to comprehend. The concept eluded me, and there was a certain resistance to embracing something new. This blog is an encapsulation of how I eventually embraced Next.js, offering a fresh perspective that might help others look at this framework in a different light.&lt;/p&gt;

&lt;h2&gt;
  
  
  It's not a Replacement
&lt;/h2&gt;

&lt;p&gt;One &lt;strong&gt;BIG&lt;/strong&gt; misconception I had when I started to learn NEXT.js is that it replaces React.js, ie how I work with React and is a complete change of flow, mostly because of how it was marketed by people in tech and just the general notion of NEXT.js is so much better than just REACT.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next.js: The Meta-Framework
&lt;/h3&gt;

&lt;p&gt;What's Next.js's deal? The term "Meta-Framework" seemed bewildering at first. Let's demystify it in simple terms.&lt;/p&gt;

&lt;h4&gt;
  
  
  What is a Meta-Framework?
&lt;/h4&gt;

&lt;p&gt;if we go on to google it or the new age GPT-ing it will tell you something on the line of&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A meta-framework is a higher-level framework that provides a structure, guidelines, or common patterns for creating other frameworks. In other words, it's a framework for creating frameworks. Meta-frameworks are designed to simplify and standardize the process of developing specialized frameworks for specific purposes. ...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;and it goes on to explain this over 15 paragraphs.&lt;br&gt;&lt;br&gt;
But to keep things simple Meta-Frameworks are just &lt;em&gt;a structure added over an existing system&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Still confused?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Meta-Frameworks make doing the same things a bit easier and in most cases just delegate the task via abstraction, like say routing in React &lt;em&gt;( the whole adding router-dom and creating the router and routes and everything)&lt;/em&gt; taken care of, image optimization and other list of things which NEXT markets.&lt;/p&gt;

&lt;p&gt;BUT, Next.js doesn't just stop there, unlike what I hope most people think about NEXT.js&lt;/p&gt;

&lt;h2&gt;
  
  
  It's not a Frontend Framework
&lt;/h2&gt;

&lt;p&gt;And I know it sounds confusing React is a Frontend Library, and Next is a Meta-Framework based around it, so it must be a frontend Framework. and I was the same until I tried to understand how NEXT works and how it is making React better performant and demystifying concepts like SSG&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding Next.js
&lt;/h3&gt;

&lt;p&gt;I learned NEXT.js is a &lt;strong&gt;Backend Framework&lt;/strong&gt; that just utilizes React.js to provide a frontend, I know it might sound confusing but let me make it more clear.&lt;/p&gt;

&lt;p&gt;What NEXT does is uses build tools to convert your React js Frontend Pages into a well-optimized website and it does all of this based on the Backend which is an actual abstraction this Meta-Framework introduces, and which allows us to use tech like SSG as on the build time we can decide if we have to fully build the page*(Static Site Generation)* or just provide the js build like how React.js does it &lt;em&gt;(client-side rendering)&lt;/em&gt; or have the page build on request*(Server-side Rendering)*&lt;/p&gt;

&lt;h2&gt;
  
  
  Clarity Emerges
&lt;/h2&gt;

&lt;p&gt;This explains a lot of things and answers a lot of questions I had about the framework, like why can I write APIS, do I need to write a separate Backend then? how will the database connection work for multiple users if I decide to go RESTful with the API other stupid questions I had talking to the community was helpful.&lt;/p&gt;

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

&lt;p&gt;I hope this writing, which started as a puzzle has transformed into a revelation and was able to help clear some misconceptions and give a new perspective to understanding how NEXT.js works and where it fits in this large world of Web development.&lt;/p&gt;

&lt;p&gt;Next.js is no mere substitute for React.js; it's a dynamic companion that amplifies and enriches the React experience.&lt;/p&gt;

&lt;p&gt;Here’s to embracing change, propelling innovation, and coding a luminous tomorrow.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Happy coding, and welcome to the remarkable world of Next.js!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>nextjs</category>
      <category>react</category>
    </item>
    <item>
      <title>Introduction to Fullstack JS</title>
      <dc:creator>Yash Chavan</dc:creator>
      <pubDate>Wed, 21 Jun 2023 07:07:51 +0000</pubDate>
      <link>https://dev.to/hunt092/introduction-to-fullstack-js-4pd8</link>
      <guid>https://dev.to/hunt092/introduction-to-fullstack-js-4pd8</guid>
      <description>&lt;p&gt;Welcome to the fascinating world of Fullstack JavaScript (JS) development! In this blog post, we'll embark on an exciting journey to explore the fundamentals, tools, and possibilities that Fullstack JS has to offer. Whether you're a beginner just starting or an experienced developer looking to expand your skill set, this guide will provide you with a solid foundation and ignite your passion for Fullstack JS development.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Fullstack JavaScript?
&lt;/h2&gt;

&lt;p&gt;Fullstack JavaScript refers to the practice of using JavaScript not only on the front end but also on the back end of web applications. Traditionally, JavaScript was primarily used for client-side programming, handling interactivity and user interfaces. However, with the advent of Node.js, JavaScript became capable of running on servers, enabling developers to build end-to-end applications using a single language.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Choose Fullstack JavaScript?
&lt;/h2&gt;

&lt;p&gt;There are several compelling reasons why Fullstack JS has gained popularity among developers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Consistency&lt;/strong&gt;: By utilizing JavaScript for both frontend and backend development, you achieve consistency in code syntax and structure, making it easier to maintain and understand your application as a whole.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Efficiency&lt;/strong&gt;: With a shared codebase, Fullstack JS allows for more efficient development processes. You can reuse components, libraries, and even some business logic between the front end and back end, saving valuable time and effort.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rapid Prototyping&lt;/strong&gt;: JavaScript's vast ecosystem of libraries and frameworks, such as React, Angular, and Express, empowers Fullstack JS developers to quickly prototype and build feature-rich applications with ease.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;JavaScript Mastery&lt;/strong&gt;: If you're already familiar with JavaScript, transitioning to Fullstack JS will leverage your existing knowledge, enabling you to leverage your skills and become a more versatile developer.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Essential Tools and Technologies
&lt;/h2&gt;

&lt;p&gt;To embark on your Fullstack JS journey, it's essential to familiarize yourself with the core tools and technologies used in this domain. Some key components you'll encounter include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Node.js&lt;/strong&gt;: An open-source, server-side runtime environment that allows you to run JavaScript on servers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Express.js&lt;/strong&gt;: A fast and minimalist web application framework for Node.js, ideal for building robust APIs and backend services.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;React (any other framework also works)&lt;/strong&gt;: A popular JavaScript library for building user interfaces. React enables you to create dynamic, interactive front-end applications efficiently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MongoDB&lt;/strong&gt;: A powerful NoSQL database that seamlessly integrates with Node.js, allowing you to store and retrieve data for your applications.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Learning Path Ahead
&lt;/h2&gt;

&lt;p&gt;Throughout this blog series, we'll dive deeper into Fullstack JS development, covering topics such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Setting up your Fullstack JS development environment&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Building RESTful APIs with Node.js and Express.js&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Creating dynamic frontend interfaces with React&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Database integration and management with MongoDB&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Authentication and security best practices&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deploying Fullstack JS applications to production&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end of this series, you'll have a comprehensive understanding of Fullstack JS development and be equipped with the skills to create robust, scalable, and modern web applications.&lt;/p&gt;

&lt;p&gt;Are you ready to embark on this thrilling Fullstack JS adventure? Let's dive in and unlock the endless possibilities of Fullstack JavaScript development!&lt;/p&gt;

&lt;p&gt;In the next blog post, I will guide you through setting up your Fullstack JS development environment. Stay tuned!&lt;/p&gt;

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

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>What are Multi-Stage Docker Images?</title>
      <dc:creator>Yash Chavan</dc:creator>
      <pubDate>Tue, 20 Jun 2023 14:18:43 +0000</pubDate>
      <link>https://dev.to/hunt092/what-are-multi-stage-docker-images-3l36</link>
      <guid>https://dev.to/hunt092/what-are-multi-stage-docker-images-3l36</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Let's start from the basics
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Docker&lt;/strong&gt;! It's an awesome tool that lets you create, deploy, and run applications in these neat little containers. Think of them like tiny virtual machines, but with just enough resources to run your app. It's fantastic since it means you can run your application on any platform, &lt;em&gt;from your laptop to the cloud!&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Power of Docker Images
&lt;/h3&gt;

&lt;p&gt;Docker images are one of the key elements that make Docker so powerful. These are pre-built, pre-configured packages that include everything your app requires to execute - code, libraries, and dependencies. They're like the ultimate Lego set for developing and distributing applications!&lt;/p&gt;

&lt;h3&gt;
  
  
  But what if Docker images got better?
&lt;/h3&gt;

&lt;p&gt;That's where multi-stage Docker images come in. They're like the superheroes of the Docker world - able to create smaller, faster, and more efficient images by separating the build and runtime environment. With multi-stage Docker images, you can save disk space, reduce build times, and even improve security!&lt;/p&gt;

&lt;h2&gt;
  
  
  The Magic of Multi-Stage Docker Images
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What are Multi-Stage Docker Images?
&lt;/h3&gt;

&lt;p&gt;Are you tired of creating bloated Docker images that take forever to build and deploy? Multi-stage Docker images to the rescue! These superheroes of the Docker world allow you to create smaller, faster, and more secure images by separating the build and runtime environment.&lt;br&gt;&lt;br&gt;
Let's say you're building a TypeScript app with Node.js as the runtime environment. With a traditional Docker image, you'd have to include everything in the same image, leading to a larger image size. But with a multi-stage Docker image, you can create a lean and mean image that only includes what's necessary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# First stage: build environment&lt;/span&gt;
FROM node:14-alpine as build
WORKDIR /app
COPY package&lt;span class="k"&gt;*&lt;/span&gt;.json ./
RUN npm &lt;span class="nb"&gt;install
&lt;/span&gt;COPY &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
RUN npm run build

&lt;span class="c"&gt;# Second stage: runtime environment&lt;/span&gt;
FROM node:14-alpine
WORKDIR /app
COPY &lt;span class="nt"&gt;--from&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;build /app/dist ./dist
COPY package&lt;span class="k"&gt;*&lt;/span&gt;.json ./
RUN npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--only&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production
CMD &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"npm"&lt;/span&gt;, &lt;span class="s2"&gt;"start"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Traditional vs. Multi-Stage Docker Images
&lt;/h2&gt;

&lt;p&gt;Traditional Docker images use a single stage to build and package an application, which means that the image includes both the build and runtime environment. This can make the image larger and less efficient.&lt;br&gt;&lt;br&gt;
On the other hand, multi-stage Docker images allow you to create smaller, more efficient images by separating the build and runtime environment. Each stage in a multi-stage Docker image can have its own base image, dependencies, and build instructions. You can use the COPY command to copy files between stages, and the final stage is used to create the final image that will be deployed.&lt;/p&gt;

&lt;p&gt;Let's consider the above example of a Typescript app that you want to deploy to a serverless platform like AWS Lambda. With traditional Docker images, you would include both the build and runtime environment in a single image, which would result in a larger image size. This can slow down deployment times and make your app less responsive. Here's an example Dockerfile for a TypeScript app with traditional images:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Tradional Docker image&lt;/span&gt;
FROM node:14-alpine
WORKDIR /app
COPY package&lt;span class="k"&gt;*&lt;/span&gt;.json ./
RUN npm &lt;span class="nb"&gt;install 
&lt;/span&gt;COPY &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
RUN npm run build
CMD &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"npm"&lt;/span&gt;, &lt;span class="s2"&gt;"start"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, we not only install all dependencies, regardless of whether they are required in the production environment, but we also have the TypeScript code and the transpiled JavaScript, thus producing two copies of the same code.&lt;/p&gt;

&lt;p&gt;Whereas with multi-stage Docker images, you can keep the size of your Docker image small by separating the build and runtime environment into separate stages. Here's an example Dockerfile for a TypeScript app that uses multi-stage Docker images:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Build stage&lt;/span&gt;
FROM node:14 AS build
WORKDIR /app
COPY package&lt;span class="k"&gt;*&lt;/span&gt;.json ./
RUN npm &lt;span class="nb"&gt;install
&lt;/span&gt;COPY &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
RUN npm run build

&lt;span class="c"&gt;# Runtime stage&lt;/span&gt;
FROM node:14-alpine
WORKDIR /app
COPY &lt;span class="nt"&gt;--from&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;build /app/dist ./dist
COPY package&lt;span class="k"&gt;*&lt;/span&gt;.json ./
RUN npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--only&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production
CMD &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"npm"&lt;/span&gt;, &lt;span class="s2"&gt;"run"&lt;/span&gt;, &lt;span class="s2"&gt;"start"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Demystifying Multi-Stage Docker Images
&lt;/h2&gt;

&lt;p&gt;Multi-stage Docker images work like a well-coordinated team, with each stage performing a specific task. In the first stage, you can use a TypeScript base image and include your source code and build tools. This stage compiles your TypeScript code and creates a build artifact.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;FROM node:14 AS build
WORKDIR /app
COPY package&lt;span class="k"&gt;*&lt;/span&gt;.json ./
RUN npm &lt;span class="nb"&gt;install
&lt;/span&gt;COPY &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;
RUN npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next stage, you can use a Node.js base image and copy only the runtime dependencies needed to run your app from the previous stage. By keeping the runtime environment separate, you can create a smaller, more efficient Docker image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;FROM node:14-alpine
WORKDIR /app
COPY &lt;span class="nt"&gt;--from&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;build /app/dist ./dist
COPY package&lt;span class="k"&gt;*&lt;/span&gt;.json ./
RUN npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--only&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production
CMD &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"npm"&lt;/span&gt;, &lt;span class="s2"&gt;"run"&lt;/span&gt;, &lt;span class="s2"&gt;"start"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final stage can then create the final image that's ready for deployment. And the best part? With this approach, you can significantly reduce the size of your Docker image, making it faster and easier to deploy your TypeScript app.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Benefits of Multi-Stage Docker Images
&lt;/h3&gt;

&lt;p&gt;They offer numerous benefits, including smaller image sizes, faster builds, reduced attack surface, and improved maintainability. By separating the build and runtime environments, you can create leaner, more efficient Docker images that are perfect for containerizing your applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Thoughts
&lt;/h3&gt;

&lt;p&gt;Multi-stage Docker images are particularly useful for applications with complex build processes or large dependencies, such as TypeScript applications. They also shine when deploying to serverless platforms like AWS Lambda or Kubernetes Clusters for easy and fast management.&lt;/p&gt;

&lt;h3&gt;
  
  
  Further reading and learning
&lt;/h3&gt;

&lt;p&gt;If you're interested in learning more about using Docker with TypeScript, check out my blog post "&lt;a href="https://dev.to/hunt092/using-typescript-with-docker-a-guide-to-containerize-your-applications-4m9d"&gt;Using TypeScript with Docker: A Guide to Containerize Your Applications&lt;/a&gt;" &lt;em&gt;shameless plug&lt;/em&gt;. This comprehensive guide covers everything from setting up a Docker environment to deploying your containerized TypeScript app. Additionally, the Docker documentation and online tutorials offer plenty of resources for further learning.&lt;/p&gt;

&lt;p&gt;So, what are you waiting for? Begin using multi-stage Docker images to optimize your applications immediately! Don't forget to like and follow my blog to discover much more.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>devops</category>
    </item>
    <item>
      <title>Using TypeScript with Docker: A Guide to Containerize Your Applications</title>
      <dc:creator>Yash Chavan</dc:creator>
      <pubDate>Tue, 20 Jun 2023 14:16:40 +0000</pubDate>
      <link>https://dev.to/hunt092/using-typescript-with-docker-a-guide-to-containerize-your-applications-4m9d</link>
      <guid>https://dev.to/hunt092/using-typescript-with-docker-a-guide-to-containerize-your-applications-4m9d</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Before we get into using Typescript and Docker together, it is important to understand what these technologies are on their own&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;Typescript&lt;/em&gt;&lt;/strong&gt; is a programming language that extends JavaScript by adding new features such as type annotations, class and interface definitions, modules, decorators, and more. It's particularly useful for large-scale projects and for developing robust and maintainable code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Docker&lt;/strong&gt; is a platform that allows developers to create, deploy, and run applications in containers. Containers are lightweight, portable, and self-sufficient environments that can run on any machine that supports Docker, regardless of the underlying infrastructure, it provides several benefits, including portability, isolation, scalability, automation, and standardization&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding these two technologies makes it clear why knowing how to combine the two to build and deploy your applications can be beneficial&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits of using TypeScript and Docker
&lt;/h2&gt;

&lt;p&gt;Using Typescript and Docker together gives the clear benefit of having &lt;em&gt;robust and reliable apps&lt;/em&gt; but there are several more benefits when building and deploying applications:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Type safety: TypeScript's type annotations can help catch errors early during development, making the code more predictable and easier to understand. This can reduce the number of bugs in the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improved development experience: TypeScript's advanced type system also comes with powerful autocomplete capabilities, providing developers with suggestions for properties, methods, and parameters, making coding faster and more efficient.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Better maintainability: TypeScript's class and interface definitions, modules, and decorators can make the code more organized and reusable, making it easier to maintain and update the application over time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Consistency and reliability in deployment: Docker allows you to package your application and its dependencies into a single container, which can be easily deployed to any environment. This makes deployment more consistent and reliable and can help to reduce the number of environment-specific bugs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scalability: Docker allows for easy scaling of applications by running multiple containers, which can handle increased traffic and workloads.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Portability: Docker containers can be easily moved between different environments, such as development, staging, and production. This ensures consistency and reduces complexity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Isolation: Docker allows multiple applications or services to run on the same machine without interfering with each other, improving the security and stability of the application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Improved collaboration: Docker provides a consistent set of tools and technologies that can be used across different environments (So no more, &lt;em&gt;"but it worked on my machine"&lt;/em&gt; from your peers), making it easier for developers to collaborate and share their work.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Setting up a TypeScript and Docker project
&lt;/h2&gt;

&lt;p&gt;Let's take an example of a simple Nodejs application to get/create todos in typescript. (&lt;em&gt;make sure you have&lt;/em&gt; &lt;a href="https://nodejs.org"&gt;&lt;strong&gt;&lt;em&gt;Node&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;&lt;em&gt;,&lt;/em&gt; &lt;strong&gt;&lt;em&gt;npm and&lt;/em&gt;&lt;/strong&gt; &lt;a href="https://www.docker.com/products/docker-desktop/"&gt;&lt;strong&gt;&lt;em&gt;Docker&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; &lt;em&gt;installed to follow along)&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 - Setting up
&lt;/h3&gt;

&lt;p&gt;To get started open your directory and setup your node app as usual with express.js, or follow the code given below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;express body-parser
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2- Adding TypeScript
&lt;/h3&gt;

&lt;p&gt;To add Typescript run the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; typescript @types/express nodemon ts-node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will install typescript as a dev dependency along with types for express, and nodemon which we will use for testing the app locally along with ts-node&lt;/p&gt;

&lt;p&gt;TypeScript uses a file called &lt;code&gt;tsconfig.json&lt;/code&gt; to configure the compiler options for a project. Create a &lt;code&gt;tsconfig.json&lt;/code&gt; file in the root of the project directory and paste the following JSON&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"module"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"commonjs"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"esModuleInterop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"es6"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"moduleResolution"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"sourceMap"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"outDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"build"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"lib"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"es2015"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, your directory should 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;--node_modules/ 
--package.json 
--tsconfig.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3 - Creating the App
&lt;/h3&gt;

&lt;p&gt;Then create &lt;code&gt;App.ts&lt;/code&gt; file ( you can name it anything you like I prefer App.ts) and paste the code below&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;bodyParser&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;body-parser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Todo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;task&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="nl"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;bodyParser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;json&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;todos&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Todo&lt;/span&gt;&lt;span class="p"&gt;[]&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="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;task&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Take out trash&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;id&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="na"&gt;task&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Do laundry&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;completed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="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;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World&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="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/todos&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/todos&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="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;newTodo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Todo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&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="nx"&gt;todos&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newTodo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newTodo&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Server is running on port 3000&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;At this point, your directory should be looking 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;--node_modules/
--package.json
--tsconfig.json
--App.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4 -Time to test the app
&lt;/h3&gt;

&lt;p&gt;To check if the app runs, we already have installed the tools need nodemon which uses ts-node to auto compile and autorun our app with changes, BUT we need to make some changes in our package.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"App.ts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;&lt;span class="w"&gt;  
    &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"nodemon"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node build/App.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tsc --project ./"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;dev&lt;/code&gt; is used for testing, while the &lt;code&gt;build&lt;/code&gt; is used to compile our typescript code and &lt;code&gt;start&lt;/code&gt; to run the compiled javascript app.&lt;/p&gt;

&lt;p&gt;To start the test server run the following command&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Once nodemon finishes you should see the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;nodemon
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] 2.0.20
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] to restart at any &lt;span class="nb"&gt;time&lt;/span&gt;, enter &lt;span class="sb"&gt;`&lt;/span&gt;rs&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] watching path&lt;span class="o"&gt;(&lt;/span&gt;s&lt;span class="o"&gt;)&lt;/span&gt;: &lt;span class="k"&gt;*&lt;/span&gt;.&lt;span class="k"&gt;*&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] watching extensions: ts,json
&lt;span class="o"&gt;[&lt;/span&gt;nodemon] starting &lt;span class="sb"&gt;`&lt;/span&gt;ts-node App.ts&lt;span class="sb"&gt;`&lt;/span&gt;
Server is running on port 3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5 - Setting up Docker
&lt;/h3&gt;

&lt;p&gt;The next step is to set up Docker, we do that by creating a &lt;code&gt;Dockerfile&lt;/code&gt; and paste the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="s"&gt;FROM node:14-alpine&lt;/span&gt;
&lt;span class="s"&gt;WORKDIR /app&lt;/span&gt;
&lt;span class="s"&gt;COPY . .&lt;/span&gt;
&lt;span class="s"&gt;RUN npm install&lt;/span&gt;
&lt;span class="s"&gt;RUN npm run build&lt;/span&gt;
&lt;span class="s"&gt;EXPOSE &lt;/span&gt;&lt;span class="m"&gt;3000&lt;/span&gt;
&lt;span class="s"&gt;CMD ["npm","run", "start"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the Dockerfile which is the schema to create your docker image,&lt;/p&gt;

&lt;p&gt;the &lt;code&gt;COPY&lt;/code&gt; command copies everything in the root directory to the app directory inside the docker image, to avoid us also copying the node modules we need to create a &lt;code&gt;.dockerIgnore&lt;/code&gt; file and add the following inside it,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight make"&gt;&lt;code&gt;&lt;span class="err"&gt;/node_modules&lt;/span&gt;

&lt;span class="err"&gt;/build&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now to create the docker image run this command in your terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; tsdocker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create the docker image&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-p&lt;/span&gt; 3000:3000 tsdocker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can open &lt;code&gt;HTTP://Localhost:3000&lt;/code&gt; and get the message &lt;em&gt;Hello World&lt;/em&gt; on your screen and there you have it. You have set up your typescript app with docker. We will further how to deploy with a platform like render, in some future blog&lt;/p&gt;

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

&lt;p&gt;Using TypeScript and Docker together can bring many benefits to a Node.js application. TypeScript provides a way to catch bugs early on by providing type checking and interfaces, while Docker allows for easy deployment and scaling of the application by packaging it in a lightweight container. Additionally, Docker provides a consistent environment regardless of the underlying infrastructure, which can prevent issues caused by differences between development and production environments. Furthermore, TypeScript and Docker make it simple to test the application in various environments as well as manage infrastructure and scaling. Finally, they can help to improve the overall development and deployment process by automating the building, testing, and deployment of code changes.&lt;/p&gt;

&lt;p&gt;However, we haven't covered all the things, some advanced things you can cover on your own or through my future blogs are using &lt;code&gt;multi-stage build&lt;/code&gt; in &lt;code&gt;Dockerfile&lt;/code&gt; or using &lt;code&gt;docker compose&lt;/code&gt; to run multiple containers.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>docker</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Getting started with Web-dev</title>
      <dc:creator>Yash Chavan</dc:creator>
      <pubDate>Tue, 20 Jun 2023 14:14:54 +0000</pubDate>
      <link>https://dev.to/hunt092/getting-started-with-web-dev-3dlm</link>
      <guid>https://dev.to/hunt092/getting-started-with-web-dev-3dlm</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Starting to get into web development is often taken in this step learn HTML jump on CSS and a framework like bootstrap and then JavaScript finally landing on the framework and boom you are done. This is somewhat wrong as we are not only skipping over the foundation but also just oversimplifying web development&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding the Foundation
&lt;/h2&gt;

&lt;p&gt;Understanding the foundation of web development is simple as it is covered in the name of &lt;strong&gt;the web&lt;/strong&gt;. However, there is a common misunderstanding regarding the distinction between &lt;strong&gt;the web and the internet.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between the Web and the Internet
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;The Internet is a global network of networks while the Web, also referred to formally as World Wide Web (www) is a collection of information that is accessed via the Internet. Another way to look at this difference is; the Internet is infrastructure while the Web is served on top of that infrastructure. Alternatively, the Internet can be viewed as a big book store while the Web can be viewed as a collection of books on that store. At a high level, we can even think of the Internet as hardware and the Web as software!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;once the difference is clear next is how this software communicates over this massive network it is built on, more technically known as Protocols, to be specific, and the important one for now HTTP.&lt;/p&gt;

&lt;h3&gt;
  
  
  So what is HTTP?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;The Hypertext Transfer Protocol (HTTP) is the foundation of the World Wide Web and is used to load web pages using hypertext links. HTTP is an application layer protocol designed to transfer information between networked devices and runs on top of other layers of the network protocol stack. A typical flow over HTTP involves a client machine making a request to a server, which then sends a response message.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;another important step into web dev is to understand what side of the development you want to be or to make it sound not only technical but also erotic &lt;em&gt;(weirdly)&lt;/em&gt; which end you like (namely Frontend, Backend)&lt;/p&gt;

&lt;h3&gt;
  
  
  What's your Poison?
&lt;/h3&gt;

&lt;p&gt;Front-end web developers focus on a website's client-side functions, while back-end web developers focus on a website's server-side development. Full-stack developers work with just that - the "full stack" of development technologies - and have mastery of both front and back-end technologies.&lt;/p&gt;

&lt;h4&gt;
  
  
  Front end developers
&lt;/h4&gt;

&lt;p&gt;They create the content you see when interacting with a website. This includes visual elements such as menus, buttons, and animations that can execute on a client's machine. Front-end developers use three primary languages: HTML to create a website's structure, CSS to change how a website looks, and JavaScript to create interactive elements.&lt;/p&gt;

&lt;h4&gt;
  
  
  Back end developers
&lt;/h4&gt;

&lt;p&gt;They work with the server side of a website. This involves managing web servers, interacting with databases, and using data analysis - all of which are functions the user doesn't see when interacting with the site.&lt;/p&gt;

&lt;h4&gt;
  
  
  Full Stack developers
&lt;/h4&gt;

&lt;p&gt;They do both, take care of frontend and backend both&lt;/p&gt;




&lt;p&gt;And this where learning to code can come in you now know not only how the web works but also what you wanna do on it and can respectively plan your road, though, in my opinion, it is important to learn at least basic frontend development even if you prefer backend&lt;/p&gt;

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