<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vrishali on Medium]]></title>
        <description><![CDATA[Stories by Vrishali on Medium]]></description>
        <link>https://medium.com/@jvrishali1?source=rss-76ef39311b95------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*x7nB6aqXgc_lKUr287o0ow.jpeg</url>
            <title>Stories by Vrishali on Medium</title>
            <link>https://medium.com/@jvrishali1?source=rss-76ef39311b95------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 07:50:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jvrishali1/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding JavaScript Date class]]></title>
            <link>https://medium.com/@jvrishali1/understanding-javascript-date-class-c01b01ac90f2?source=rss-76ef39311b95------2</link>
            <guid isPermaLink="false">https://medium.com/p/c01b01ac90f2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[data-class]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Vrishali]]></dc:creator>
            <pubDate>Wed, 22 Jul 2026 17:15:42 GMT</pubDate>
            <atom:updated>2026-07-22T17:15:42.519Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d-OihiNDDLF1Dj4bij0Mrw.png" /><figcaption>javascript date class</figcaption></figure><p>Dates seem simple until you actually need to work with one. Then suddenly you’re comparing timestamps, formatting things for different locales, and running into a “day 6 instead of day 7” bug that turns out to be a single 0-indexed month messing everything up.</p><h3><strong>Background</strong></h3><blockquote>Date is a built-in JavaScript class for working with dates and times. Under the hood, it stores everything as <strong>milliseconds since January 1, 1970</strong> a reference point known as the <strong><em>Unix Epoch</em></strong>.</blockquote><p>Dates are everywhere order timestamps, delivery windows, user date-of-birth, session expiry, log entries. Most real projects lean on a helper library like <strong>day.js</strong> or <strong>date-fns</strong> on top of this, because raw Date formatting is clunky. But that native class is the foundation everything else is built on, so it&#39;s worth actually understanding rather than skipping straight to the library.</p><p>And here’s the one thing to burn into memory before anything else: <strong>month is 0-indexed</strong> : January is 0, December is 11.(same for weeks : Sunday is 0, Saturday is 6) Remember this.</p><h3>Making a Date object</h3><p>There are four ways I keep running into:</p><pre>// 1. Current date and time<br>const now = new Date();<br>console.log(now); // 2025-07-06T10:30:00.000Z (your current time)<br><br>// 2. From a date string<br>const d1 = new Date(&quot;2025-01-15&quot;);<br>console.log(d1); // 2025-01-15T00:00:00.000Z<br><br>// 3. From year, month, day (month is 0-indexed!)<br>const d2 = new Date(2025, 0, 15); // Jan 15, 2025<br>console.log(d2);<br><br>// 4. From milliseconds since epoch<br>const d3 = new Date(0);<br>console.log(d3); // 1970-01-01T00:00:00.000Z</pre><p>Option 3 is where the 0-indexing thing actually bites 0 means January, not &quot;invalid&quot; or some placeholder. I still double-check this one every time.</p><h3>Pulling pieces out of a date</h3><p>Once you’ve got a Date object, these get you the individual parts:</p><pre>const now = new Date(&quot;2025-07-06T10:30:45&quot;);<br>console.log(now.getFullYear());  // 2025<br>console.log(now.getMonth());     // 6  ← July (0-indexed!)<br>console.log(now.getDate());      // 6  ← day of month<br>console.log(now.getDay());       // 0  ← day of week (0=Sun, 6=Sat)<br>console.log(now.getHours());     // 10<br>console.log(now.getMinutes());   // 30<br>console.log(now.getSeconds());   // 45<br>console.log(now.getTime());      // milliseconds since epoch</pre><p>getMonth() returning 6 for July same gotcha, again. And don&#39;t mix up getDay() with getDate(): one&#39;s the day of the <em>week</em>, the other&#39;s the day of the <em>month</em>. I mixed these up more than once before it stuck.</p><h3>Changing pieces of a date</h3><p>You can mutate a Date directly too:</p><pre>const d = new Date(&quot;2025-07-06&quot;);<br>d.setFullYear(2026);<br>d.setMonth(11);     // December<br>d.setDate(25);      // 25th<br>console.log(d); // 2026-12-25</pre><h3>Making a date actually readable</h3><p>A raw Date object isn&#39;t something you&#39;d want to show a user. These methods turn it into something presentable:</p><pre>const d = new Date(&quot;2025-07-06&quot;);<br>console.log(d.toDateString());<br>// Sun Jul 06 2025<br>console.log(d.toLocaleDateString());<br>// 7/6/2025  (format depends on your system locale)<br>console.log(d.toLocaleDateString(&quot;en-IN&quot;));<br>// 06/07/2025  ← Indian format<br>console.log(d.toLocaleString());<br>// 7/6/2025, 12:00:00 AM  (date + time)<br>console.log(d.toISOString());<br>// 2025-07-06T00:00:00.000Z  ← used in APIs, databases</pre><p>Out of all of these, toISOString() is the one I use most it&#39;s the standard format APIs and databases expect, so it shows up the second you start touching backend data.</p><h3>Date.now() : when you just need a timestamp</h3><p>No need to build a full object if all you want is “what time is it right now, in milliseconds”:</p><pre>console.log(Date.now()); // 1751234567890  (some big number)</pre><p>I mostly reach for this to measure how long something takes to run:</p><pre>const start = Date.now();<br>// some code running...<br>for (let i = 0; i &lt; 1000000; i++) {}<br>const end = Date.now();<br>console.log(`Time taken: ${end - start} ms`); // Time taken: 4 ms</pre><h3>Comparing two dates</h3><p>Since Date objects are really just numbers underneath (milliseconds since the epoch), you can subtract one from another:</p><pre>const d1 = new Date(&quot;2025-01-01&quot;);<br>const d2 = new Date(&quot;2025-07-06&quot;);<br>const diff = d2 - d1; // milliseconds<br>const days = diff / (1000 * 60 * 60 * 24);<br>console.log(`Difference: ${days} days`); // Difference: 186 days</pre><p>That 1000 * 60 * 60 * 24 looks intimidating the first time, but it&#39;s just unit conversion, one step at a time — ms to seconds, seconds to minutes, minutes to hours, hours to days. Write it once and it sticks.</p><h3>Putting it together an age calculator</h3><p>Here’s where it all comes together in something you’d actually build:</p><pre>function calculateAge(birthDateStr) {<br>  const birth = new Date(birthDateStr);<br>  const today = new Date();<br>let age = today.getFullYear() - birth.getFullYear();<br>// Check if birthday has passed this year<br>  const monthDiff = today.getMonth() - birth.getMonth();<br>  if (monthDiff &lt; 0 || (monthDiff === 0 &amp;&amp; today.getDate() &lt; birth.getDate())) {<br>    age--;<br>  }<br>return age;<br>}<br>console.log(calculateAge(&quot;2003-11-20&quot;)); // 21</pre><p>The part worth actually paying attention to is that if check it&#39;s not just subtracting years, it&#39;s checking whether the birthday has happened <em>yet</em> this year and knocking off a year if not. That extra bit of logic is what separates &quot;technically runs&quot; from &quot;actually correct,&quot; and I&#39;d rather understand it than just copy it.</p><h3>The bits I keep having to look up</h3><ul><li>getFullYear() — the 4-digit year</li><li>getMonth() — 0 to 11, remember January is 0</li><li>getDate() — day of the month, 1 to 31</li><li>getDay() — day of the week, 0 (Sunday) to 6</li><li>getTime() / Date.now() — milliseconds since the epoch</li><li>toISOString() — the API/database-friendly format</li><li>toLocaleDateString() — whatever format makes sense for your locale</li></ul><p>If none of this sticks the first time, that’s fine that’s basically what this list is for.</p><p>So that’s Date in a nutshell small on the surface, but it&#39;s the kind of thing that quietly powers half of every real app you&#39;ll build. The epoch and the 0-indexed month are really the only two ideas doing all the work here; everything else is just methods built on top of them.</p><p>Has the month 0-indexing bug ever gotten you? I’d genuinely like to hear your worst Date-related debugging story in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c01b01ac90f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Objects: The One Concept You’ll Use in Every Single File]]></title>
            <link>https://medium.com/@jvrishali1/javascript-objects-the-one-concept-youll-use-in-every-single-file-501b1f329fcf?source=rss-76ef39311b95------2</link>
            <guid isPermaLink="false">https://medium.com/p/501b1f329fcf</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[objects]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[js]]></category>
            <dc:creator><![CDATA[Vrishali]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 07:38:09 GMT</pubDate>
            <atom:updated>2026-07-21T07:38:09.762Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDBEFWJP1wcJOB5axKHwHg.png" /><figcaption>object in javascript</figcaption></figure><p>If classes are the blueprint, objects are the actual <em>thing</em> you’re working with almost every minute you write JavaScript. Once you understood objects properly, a lot of other confusing stuff API responses, React props, function arguments will suddenly stop feeling like separate topics and started feeling like the same idea, over and over.</p><p><strong>Definition</strong> : An <strong>object</strong> is simply a collection of <strong>key-value pairs</strong>. It groups related data (and even behavior) together in one place.</p><p>Think of a real person: they have a name, an age, a job. An object in JS stores all of that together, instead of scattering it across separate variables.</p><h3>Why This Is Worth Mastering</h3><p>At big tech companies, nearly everything you touch as a JS developer is an object in disguise. Every API response you get back is JSON which is just a JavaScript object. Every React component’s props and state? Objects. Every database record you map into your code? An object.</p><p>If you only deeply understand one JS concept before your next interview or project, make it this one.</p><h3>Basic Syntax</h3><pre>const objectName = {<br>  key1: value1,<br>  key2: value2,<br>  key3: value3<br>};</pre><p>Keys are also called <strong>properties</strong>. Values can be anything a string, number, array, function, or even another object.</p><h3>Your First Object</h3><pre>const person = {<br>  name: &quot;Alice&quot;,<br>  age: 22,<br>  city: &quot;Mumbai&quot;<br>};</pre><pre>console.log(person);<br>// { name: &#39;Alice&#39;, age: 22, city: &#39;Mumbai&#39; }</pre><h3>Accessing Properties</h3><p>There are two ways to read a value out of an object:</p><pre>const person = {<br>  name: &quot;Alice&quot;,<br>  age: 22<br>};<br>// 1. Dot notation (most common)<br>console.log(person.name);   // Alice<br>// 2. Bracket notation (use when the key is dynamic or has spaces)<br>console.log(person[&quot;age&quot;]); // 22<br>const key = &quot;name&quot;;<br>console.log(person[key]);   // Alice  ← bracket notation shines here</pre><p>Dot notation is what you’ll use 90% of the time. Bracket notation becomes essential the moment your key is stored in a variable, like in the last example above that’s a pattern you’ll see constantly once you start writing dynamic code.</p><h3>Adding, Updating, and Deleting Properties</h3><p>Objects aren’t fixed once created you can reshape them freely:</p><pre>const car = {<br>  brand: &quot;Toyota&quot;<br>};<br>// Add<br>car.model = &quot;Camry&quot;;<br>console.log(car); // { brand: &#39;Toyota&#39;, model: &#39;Camry&#39; }<br>// Update<br>car.brand = &quot;Honda&quot;;<br>console.log(car.brand); // Honda<br>// Delete<br>delete car.model;<br>console.log(car); // { brand: &#39;Honda&#39; }</pre><h3>Methods: Functions Living Inside Objects</h3><p>When a function is stored as a value inside an object, it’s called a <strong>method</strong>.(thats the difference between function and method here)</p><pre>const person = {<br>  name: &quot;Alice&quot;,<br>  greet: function() {<br>    console.log(&quot;Hi, I am &quot; + this.name);<br>  }<br>};</pre><pre>person.greet(); // Hi, I am Alice</pre><p>You’ll almost always see the shorter, modern syntax instead:</p><pre>const person = {<br>  name: &quot;Alice&quot;,<br>  greet() {                          // cleaner — no &#39;function&#39; keyword<br>    console.log(`Hi, I am ${this.name}`);<br>  }<br>};</pre><pre>person.greet(); // Hi, I am Alice</pre><p>this inside a method refers to the object itself. Here, this.name means &quot;the name property of whichever object called this method.&quot;</p><pre>const student = {<br>  name: &quot;Priya&quot;,<br>  marks: 95,<br>  result() {<br>    console.log(`${this.name} scored ${this.marks}`);<br>  }<br>};<br>student.result(); // Priya scored 95</pre><h3>Nested Objects</h3><p>Objects can contain other objects this is how real-world data usually looks, especially anything coming from an API.</p><pre>const employee = {<br>  name: &quot;Amit&quot;,<br>  address: {<br>    city: &quot;Bangalore&quot;,<br>    state: &quot;Karnataka&quot;,<br>    pin: 560001<br>  }<br>};<br>console.log(employee.address.city);    // Bangalore<br>console.log(employee.address.pin);     // 560001</pre><h3>Arrays Inside Objects</h3><p>Just as objects can hold objects, they can hold arrays too:</p><pre>const student = {<br>  name: &quot;Sara&quot;,<br>  subjects: [&quot;Math&quot;, &quot;Science&quot;, &quot;English&quot;]<br>};<br>console.log(student.subjects[0]);      // Math<br>console.log(student.subjects.length);  // 3</pre><h3>Looping Over an Object: for...in</h3><p>Arrays have their familiar loops, but objects need a different tool since they’re not indexed by number:</p><pre>const phone = {<br>  brand: &quot;Samsung&quot;,<br>  model: &quot;S24&quot;,<br>  price: 80000<br>};<br>for (let key in phone) {<br>  console.log(key + &quot; : &quot; + phone[key]);<br>}<br>// brand : Samsung<br>// model : S24<br>// price : 80000</pre><h3>Useful Built-in Object Methods</h3><p>These three show up constantly in real projects especially once you start working with API data or rendering lists in React:</p><pre>const user = {<br>  name: &quot;Neha&quot;,<br>  age: 24,<br>  city: &quot;Delhi&quot;<br>};<br><br>// Get all keys<br>console.log(Object.keys(user));<br>// [&#39;name&#39;, &#39;age&#39;, &#39;city&#39;]<br><br>// Get all values<br>console.log(Object.values(user));<br>// [&#39;Neha&#39;, 24, &#39;Delhi&#39;]<br><br>// Get key-value pairs as arrays<br>console.log(Object.entries(user));<br>// [[&#39;name&#39;,&#39;Neha&#39;], [&#39;age&#39;,24], [&#39;city&#39;,&#39;Delhi&#39;]]</pre><h3>Object.assign()</h3><p>Object.assign() copies properties from one or more source objects into a target object.</p><pre>Object.assign(target, source1, source2, ...)</pre><ul><li><strong>target</strong> — the object you’re copying into</li><li><strong>source(s)</strong> — the object(s) you’re copying from</li><li>Returns the modified target object</li></ul><p>Here’s a concrete example, broken down step by step:</p><pre>const obj = { name: &quot;v&quot;, country: 91 };<br>let newObj = Object.assign({}, obj, { newProperty: &quot;newValue&quot; });<br>console.log(&quot;after Object.assign():&quot;, newObj);<br>// after Object.assign(): { name: &#39;v&#39;, country: 91, newProperty: &#39;newValue&#39; }</pre><p>What happened, piece by piece:</p><ul><li>{} — an empty object acts as the <strong>target</strong>, so the original obj stays untouched</li><li>obj — the first source, contributes name and country</li><li>{ newProperty: &quot;newValue&quot; } — the second source, adds one more property</li><li>newObj ends up with all three properties combined</li></ul><h3>Destructuring: A Clean Way to Extract Values</h3><p>This is one of the most common patterns you’ll see in modern JS and in every single React or Node codebase you open.</p><pre>const person = {<br>  name: &quot;Karan&quot;,<br>  age: 25,<br>  city: &quot;Pune&quot;<br>};<br>// Old way<br>const name = person.name;<br>const age = person.age;<br>// Destructuring (modern, clean)<br>const { name, age, city } = person;<br>console.log(name); // Karan<br>console.log(age);  // 25<br>console.log(city); // Pune</pre><p>You can also rename a property while destructuring it:</p><pre>const { name: fullName } = person;<br>console.log(fullName); // Karan</pre><h3>Spread Operator with Objects: ...</h3><p>The spread operator is used to copy or merge objects — and it’s everywhere in React, Redux, and API-handling code.</p><pre>const obj1 = { a: 1, b: 2 };<br>const obj2 = { c: 3, d: 4 };<br>// Merge two objects<br>const merged = { ...obj1, ...obj2 };<br>console.log(merged); // { a: 1, b: 2, c: 3, d: 4 }<br>// Copy an object<br>const copy = { ...obj1 };<br>console.log(copy); // { a: 1, b: 2 }<br>// Override a property while copying<br>const updated = { ...obj1, b: 99 };<br>console.log(updated); // { a: 1, b: 99 }</pre><p>That last pattern spreading an object and then overriding one property is exactly how state updates typically work in React. Recognizing it here will make that click faster later.</p><h3>Shorthand Property Names</h3><p>When your variable name matches the key name you want, you don’t need to repeat yourself:</p><pre>const name = &quot;Rohit&quot;;<br>const age = 23;<br>// Old way<br>const user = { name: name, age: age };<br>// Shorthand (modern)<br>const user = { name, age };<br>console.log(user); // { name: &#39;Rohit&#39;, age: 23 }</pre><h3>Object vs. Array: When to Use What</h3><p>SituationUseOrdered list of itemsArray []Named, labeled dataObject {}Key-value pairsObject {}Iteration by indexArray []</p><h3>Quick Recap</h3><ol><li><strong>Properties</strong> → key-value pairs holding data</li><li><strong>Methods</strong> → key-function pairs holding behavior</li><li><strong>this</strong> → refers to the current object</li><li><strong>Nested objects / arrays</strong> → objects can hold complex, real-world shaped data</li><li><strong>for...in / </strong><strong>Object.keys/values/entries</strong> → ways to loop and inspect</li><li><strong>Destructuring &amp; spread</strong> → the clean, modern syntax you’ll see in almost every file</li></ol><p>If classes gave you the blueprint, objects are what you actually build, pass around, and manipulate . Once destructuring and spread feel natural, reading other people’s code especially React and Node projects gets noticeably easier.</p><p><em>Which of these tripped you up the most nested objects, destructuring, or the spread operator? Drop a comment, I’d love to know if my experience matches yours.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=501b1f329fcf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Classes: The Blueprint That Finally Made Sense to Me]]></title>
            <link>https://medium.com/@jvrishali1/javascript-classes-the-blueprint-that-finally-made-sense-to-me-b7bc2e44256e?source=rss-76ef39311b95------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7bc2e44256e</guid>
            <category><![CDATA[javascript-class]]></category>
            <category><![CDATA[javascript-fundamental]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Vrishali]]></dc:creator>
            <pubDate>Mon, 20 Jul 2026 06:03:07 GMT</pubDate>
            <atom:updated>2026-07-20T06:03:07.187Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S_bu1JsKw_xb-gI-XJppQg.png" /><figcaption>javascriopt class : car</figcaption></figure><h3>JavaScript Classes : The Blueprint That Finally Made Sense to Me</h3><p>One simple idea: a class is just a <strong>blueprint</strong>.</p><p>Think about an <strong>architect</strong>. They don’t build a house from scratch every single time they draw one blueprint, and then use it to build as many similar houses/structures as they want. A JavaScript class works the same way. You define the blueprint once, and then create as many <strong>objects</strong> from it as you need.</p><p>Once that clicked, everything else will start making sense. Here’s the breakdown once you get that you’ll never forget .</p><h3>Why This Actually Matters (Not Just Interview Trivia)</h3><p>Before ES6 (2015), JavaScript used <strong>constructor functions</strong> to do this same job but they were messy and hard to read. Classes cleaned that up, and now they’re the industry standard.</p><p>This isn’t just a beginner exercise either. At companies like Google, classes show up everywhere: <strong>data models, service layers, UI components</strong> (React still supports class components, even though hooks are more common now), and classic design patterns like Singleton and Factory. Understanding this foundation pays off well beyond your first project.</p><p>If you’re a fresher, here’s the good news: you don’t need to memorize everything. Focus on <strong><em>constructor → methods → inheritance → super</em></strong>.</p><p>The Basic Syntax</p><pre>class ClassName {<br>  constructor() {<br>    // runs automatically when object is created<br>  }  methodName() {<br>    // behaviour<br>  }<br>}</pre><h3>Your First Class</h3><p>Let’s make this concrete with a Car blueprint:</p><pre>class Car {<br>  constructor(brand, model) {<br>    this.brand = brand;   // property<br>    this.model = model;   // property<br>  }<br>describe() {<br>    console.log(`This car is a ${this.brand} ${this.model}`);<br>  }<br>}// Creating objects (instances) from the blueprint<br>const car1 = new Car(&quot;Toyota&quot;, &quot;Camry&quot;);<br>const car2 = new Car(&quot;Tesla&quot;, &quot;Model 3&quot;);<br>car1.describe(); // This car is a Toyota Camry<br>car2.describe(); // This car is a Tesla Model 3</pre><p>The new keyword is what actually builds a fresh object using the blueprint. And this simply refers to whichever object is currently being created in this case, car1 or car2.</p><h3>The constructor() Method</h3><p>The constructor is a special method that runs <strong>automatically</strong> the moment you write new ClassName(). Its whole job is to set up the object&#39;s initial properties.</p><pre>class Person {<br>  constructor(name, age) {<br>    this.name = name;<br>    this.age = age;<br>  }<br>}<br>const p1 = new Person(&quot;Alice&quot;, 22);<br>console.log(p1.name); // Rahul<br>console.log(p1.age);  // 22</pre><h3>Methods: What an Object Can Do</h3><p>If properties describe what an object <em>has</em>, methods describe what it can <em>do</em>.</p><pre>class Calculator {<br>  add(a, b) {<br>    return a + b;<br>  }<br>subtract(a, b) {<br>    return a - b;<br>  }<br>}<br>const calc = new Calculator();<br>console.log(calc.add(5, 3));      // 8<br>console.log(calc.subtract(5, 3)); // 2</pre><h3>Inheritance: Passing the Blueprint Down</h3><p>One class can inherit properties and methods from another.</p><p>Think parent → child. This is where classes start to feel genuinely powerful.</p><pre>class Animal {<br>  constructor(name) {<br>    this.name = name;<br>  }<br>speak() {<br>    console.log(`${this.name} makes a sound.`);<br>  }<br>}<br>class Dog extends Animal {   // Dog inherits from Animal<br>  speak() {                  // overrides parent method<br>    console.log(`${this.name} barks.`);<br>  }<br>}<br>class Cat extends Animal {<br>  speak() {<br>    console.log(`${this.name} meows.`);<br>  }<br>}<br>const d = new Dog(&quot;Bruno&quot;);<br>const c = new Cat(&quot;Whiskers&quot;);<br>d.speak(); // Bruno barks.<br>c.speak(); // Whiskers meows.</pre><p>Both Dog and Cat reused the same Animal blueprint, but customized their own behavior. That&#39;s the whole point of inheritance reuse what makes sense, override what doesn&#39;t.</p><h3>The super Keyword</h3><p>super lets a child class reach back and call its parent&#39;s constructor or methods.</p><pre>class Vehicle {<br>  constructor(brand) {<br>    this.brand = brand;<br>  }<br>info() {<br>    console.log(`Brand: ${this.brand}`);<br>  }<br>}<br>class Bike extends Vehicle {<br>  constructor(brand, type) {<br>    super(brand);        // calls Vehicle&#39;s constructor<br>    this.type = type;<br>  }<br>info() {<br>    super.info();        // calls Vehicle&#39;s info()<br>    console.log(`Type: ${this.type}`);<br>  }<br>}<br>const b = new Bike(&quot;Honda&quot;, &quot;Sports&quot;);<br>b.info();<br>// Brand: Honda<br>// Type: Sports</pre><p>Without super(brand), the Bike class would have no way to set up the brand property it inherited from Vehicle. It&#39;s the bridge between parent and child.</p><h3>Static Methods</h3><p>Static methods belong to the class itself, not to any individual object so you call them directly on the class, no newrequired.</p><pre>class MathHelper {<br>  static square(n) {<br>    return n * n;<br>  }<br>}<br>console.log(MathHelper.square(4)); // 16</pre><p>You’ll see this pattern constantly in utility and helper classes across real codebases.</p><h3>Getters and Setters</h3><p>Getters and setters give you control over how a property is read or written instead of just exposing raw data.</p><pre>class Student {<br>  constructor(name) {<br>    this._name = name;   // _ means &quot;internal&quot; by convention<br>  }<br>get name() {<br>    return this._name.toUpperCase();   // transforms on read<br>  }<br>set name(newName) {<br>    if (newName.length &lt; 2) {<br>      console.log(&quot;Name too short!&quot;);<br>      return;<br>    }<br>    this._name = newName;<br>  }<br>}<br>const s = new Student(&quot;rahul&quot;);<br>console.log(s.name);   // RAHUL  (getter runs)<br>s.name = &quot;R&quot;;          // Name too short!  (setter validates)<br>s.name = &quot;Ravi&quot;;<br>console.log(s.name);   // RAVI</pre><h3>Private Fields (Modern JS : ES2022)</h3><p>Use # to make a field genuinely private it can&#39;t be accessed from outside the class at all.</p><pre>class BankAccount {<br>  #balance = 0;    // private field</pre><pre>  deposit(amount) {<br>    this.#balance += amount;<br>  }</pre><pre>  getBalance() {<br>    return this.#balance;<br>  }<br>}</pre><pre>const acc = new BankAccount();<br>acc.deposit(1000);<br>console.log(acc.getBalance()); // 1000<br>console.log(acc.#balance);     // ❌ SyntaxError — can&#39;t access directly</pre><p>Big companies lean on this heavily in production code to protect sensitive data from being touched where it shouldn’t be.</p><h3>Quick Recap</h3><ol><li><strong>constructor()</strong> → sets up initial data</li><li><strong>Methods</strong> → define behavior</li><li><strong>Static methods</strong> → class-level utilities, no object needed</li><li><strong>Getters / setters</strong> → controlled property access</li><li><strong>extends + </strong><strong>super</strong> → inheritance, parent to child</li></ol><p>If you only remember one thing from this post, remember the blueprint. Everything else inheritance, super, static methods is just extra tooling built on top of that one idea.</p><p><em>What tripped you up first when you were learning classes </em><em>this, </em><em>super, or private fields? Let me know in the comments I&#39;m curious if my experience was a one-off or if everyone hits the same wall.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7bc2e44256e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>