<?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: Manjunath Shenoy</title>
    <description>The latest articles on DEV Community by Manjunath Shenoy (@forthegeeks).</description>
    <link>https://dev.to/forthegeeks</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%2F2389297%2F74527e12-9052-476f-b948-74d0574fb337.jpg</url>
      <title>DEV Community: Manjunath Shenoy</title>
      <link>https://dev.to/forthegeeks</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/forthegeeks"/>
    <language>en</language>
    <item>
      <title>C# Essentials: Operator Overloading and Custom Sorting Made Simple</title>
      <dc:creator>Manjunath Shenoy</dc:creator>
      <pubDate>Sat, 30 Nov 2024 04:44:53 +0000</pubDate>
      <link>https://dev.to/forthegeeks/c-essentials-operator-overloading-and-custom-sorting-made-simple-3pb1</link>
      <guid>https://dev.to/forthegeeks/c-essentials-operator-overloading-and-custom-sorting-made-simple-3pb1</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This blog delves into the concept of operator overloading in C#. We will also see how to perform sorting on Custom objects. While these topics are foundational, I’ve tried to present it in a way that highlights nuances we often overlook. My goal is to explain the subject so clearly that a single read-through leaves a lasting impression.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://github.com/manjusa/CsharpLearnings/tree/OperatorAndSortingCustomObjects/OperatorOverloadingAndSortingEg" rel="noopener noreferrer"&gt;GitHub Source Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;✍&lt;strong&gt;1.Introduction to Operator Overloading in C#&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅&lt;strong&gt;Operator overloading is an interesting and intuitive feature in C#&lt;/strong&gt;. It allows you to redefine how operators like +, -, *, or / behave for your custom classes or structs, making code more expressive and natural.&lt;/p&gt;

&lt;p&gt;For example, consider the System.String class. It has a static method named Concat to concatenate two strings:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;string name = "manju";
string type = "dev";
string result = string.Concat(name, type); // Output: "manjudev"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But instead of using the Concat method, you can achieve the same result with the + operator:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;string result = name + type; // Output: "manjudev"&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
This behavior is possible because the + operator is overloaded for the string class. Similarly, we can overload operators for our own classes to make them intuitive and natural to use. Let’s explore this concept with an example.&lt;/p&gt;

&lt;p&gt;✅&lt;strong&gt;Create a Calculator Class (custom class for our egample)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a Calculator class that supports arithmetic operations (+, -, *, /). Instead of relying on verbose method calls, you can define operator overloads to make the syntax more concise and intuitive.&lt;/p&gt;

&lt;p&gt;Eg code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Calculator
{
    public int Value { get; set; }

    public Calculator(int value)
    {
        Value = value;
    }

    public static Calculator operator +(Calculator a, Calculator b)
    {
        return new Calculator(a.Value + b.Value);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can use the + operator with instances of Calculator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Calculator calc1 = new Calculator(10);
Calculator calc2 = new Calculator(20);

Calculator result = calc1 + calc2;
Console.WriteLine(result.Value); // Output: 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above makes the syntax concise and intuitive, resembling built-in types.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;Addressing the IntelliSense Gap&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Operator overloading is indeed powerful, but it comes with a limitation: IntelliSense (the auto-suggestion feature in IDEs) does not show overloaded operators. This means users may not immediately realize that the &lt;strong&gt;+, -, or other operators&lt;/strong&gt; are available for the class. See egample below. When I type in “Calculator” and then a “dot”, operators methods don’t show up&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%2Fz2mapi1krlrgp1r26w9t.png" 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%2Fz2mapi1krlrgp1r26w9t.png" alt="Intellisense don’t show up for operator methods&amp;lt;br&amp;gt;
" width="110" height="137"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To bridge this gap, it’s a good practice to provide a named method alongside the operator overload. The + operator can internally call this method: For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static Calculator Add(Calculator a, Calculator b)
{
    return new Calculator(a.Value + b.Value);
}
public static Calculator operator +(Calculator a, Calculator b)
{
    return Add(a, b);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, users can either use the &lt;strong&gt;+ operator&lt;/strong&gt; OR call the &lt;strong&gt;Add method&lt;/strong&gt; directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Calculator result1 = calc1 + calc2; // Using the operator
Calculator result2 = Calculator.Add(calc1, calc2); // Using the method
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This dual approach enhances discoverability and usability, especially for developers unfamiliar with the class.&lt;/p&gt;

&lt;p&gt;✅&lt;strong&gt;When and Why to Use Operator Overloading&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Operator overloading is best suited for scenarios where custom classes represent mathematical or logical entities (e.g., vectors, matrices, fractions, or even complex numbers). However, it should be used judiciously to avoid confusion. Ensure that the overloaded operators behave in a way that aligns with user expectations.&lt;br&gt;
But let’s have a bit of fun! Think of operator overloading as going with the flow of intuition. If objects of a custom class can logically be added, multiplied, or divided, then why not make it happen? For example, imagine you have a Pest class. It might make sense that pests can be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Added (+)&lt;/strong&gt;: A swarm of pests grows when combined with another swarm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiplied (*)&lt;/strong&gt;: The infestation grows exponentially.
-** Divided (/)**: Maybe it's reduced by pest control.
By thinking creatively, operator overloading can make code more engaging and intuitive, while also injecting a touch of whimsy into programming.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✍&lt;strong&gt;2.Simplifying Sorting Custom Objects in C#: Understanding IComparable vs. IComparer&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When I started working with sorting custom objects in C#, I found it tricky to differentiate between the two interfaces: IComparable and IComparer. Both are used for sorting, but they have distinct purposes. Let's simplify the concepts with some practical analogies and example&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;✅IComparable: "I Am Comparable"&lt;/p&gt;

&lt;p&gt;Think of a class that implements IComparable as someone who compares themselves with others. For instance, imagine an Employee who is ambitious, a perfectionist, or just reflective. This person would compare their own performance or rank with another Employee.&lt;/p&gt;

&lt;p&gt;Here’s the method it exposes:&lt;br&gt;
&lt;code&gt;public int CompareTo(Employee? other)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This method allows an object of the class to compare itself to another object of the same class. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Employee : IComparable&amp;lt;Employee&amp;gt;
  {
      // Properties
      public string Name { get; set; }
      public int Age { get; set; }
      public string Role { get; set; }

      // Constructor
      public Employee(string name, int age, string role)
      {
          Name = name;
          Age = age;
          Role = role;
      }

      // Override ToString for better display
      public override string ToString()
      {
          return $"Name: {Name}, Age: {Age}, Role: {Role}";
      }

      public int CompareTo(Employee other)
      {
          if (other == null) return 1; // Current instance is greater if other is null
          return string.Compare(this.Name, other.Name, StringComparison.OrdinalIgnoreCase);
      }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅IComparer: "I Compare Others"&lt;/p&gt;

&lt;p&gt;Now, imagine an Evaluator or an Interviewer who doesn’t evaluate themselves but compares two candidates (e.g., Employees or Customers). This is the role of a class implementing IComparer.&lt;/p&gt;

&lt;p&gt;Here’s the method it exposes:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;public int Compare(Employee? x, Employee? y)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This method allows the comparer to evaluate two different objects. For instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; internal class CustomerComparer : IComparer&amp;lt;Customer&amp;gt;
 {      

     public int Compare(Customer? x, Customer? y)
     {
         if (x == null &amp;amp;&amp;amp; y == null) return 0; // Both are null, considered equal
         if (x == null) return -1; // Null is less than non-null
         if (y == null) return 1;  // Non-null is greater than null
         return string.Compare(x.Name, y.Name, StringComparison.OrdinalIgnoreCase);
     }
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Putting It All Together&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅IComparable Example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Program.cs&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;v&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;oid SortingComparableEg()
{
    List&amp;lt;Employee&amp;gt; employees = new List&amp;lt;Employee&amp;gt;{
       new ("Manju s", 30, "Software Engineer"),
        new ("Tom s", 25, "Devops"),
        new ("Kristy s", 45, "Devops")
   };

    employees.Sort();// Sort employees by Name since our Employee class does so
    Console.WriteLine("Employees sorted by Name:");
    foreach (var employee in employees)
    {
        Console.WriteLine(employee);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅IComparer Example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Program.cs&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void SortingComparerEg()
{
    List&amp;lt;Customer&amp;gt; customers = new List&amp;lt;Customer&amp;gt;{
        new ("Manju s", 30),
        new ("Tom s", 2),
        new ("Kristy", 33)
   };
    customers.Sort(new CustomerComparer());// CustomerComparer is used to sort
    Console.WriteLine("Customer sorted by Name:");
    foreach (var customer in customers)
    {
        Console.WriteLine(customer);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;In conclusion, operator overloading and sorting custom objects are foundational yet versatile features in C#. This blog aims to present these concepts in a simple, pragmatic way that leaves a lasting impression. By focusing on practical applications and clear explanations, I hope to make these topics approachable and memorable for readers. Happy coding!&lt;/p&gt;

&lt;p&gt;✅&lt;a href="https://github.com/manjusa/CsharpLearnings/tree/OperatorAndSortingCustomObjects/OperatorOverloadingAndSortingEg" rel="noopener noreferrer"&gt;GitHub Source Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;✅&lt;strong&gt;Connect with Me:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you enjoyed this post and would like to stay updated with more content like this, feel free to connect with me on social media:&lt;/p&gt;

&lt;p&gt;▶️YouTube : &lt;a href="https://www.youtube.com/c/ForTheGeeks?sub_confirmation=1" rel="noopener noreferrer"&gt;Subscribe to my YouTube Channel&lt;/a&gt; for video tutorials and tons of videos on various subjects&lt;/p&gt;

&lt;p&gt;✅Medium : &lt;a href="https://medium.com/@vnmshenoy" rel="noopener noreferrer"&gt;Follow me on Medium&lt;/a&gt; where I share more technical articles and insights.&lt;/p&gt;

&lt;p&gt;📧Email: Email me on &lt;a href="mailto:techspacedeck@gmail.com"&gt;techspacedeck@gmail.com&lt;/a&gt; for any questions, comments, or just to say hi!&lt;br&gt;
I appreciate your support and look forward to connecting with you! Happy coding! And Please do not forget to clap 👏&lt;/p&gt;

&lt;p&gt;Tip: Bookmark this blog and revisit it whenever you want a quick refresher on these operators. Happy coding! 😊&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>sorting</category>
      <category>programming</category>
      <category>overloading</category>
    </item>
    <item>
      <title>Exploring Interesting JavaScript Operators</title>
      <dc:creator>Manjunath Shenoy</dc:creator>
      <pubDate>Sun, 24 Nov 2024 23:35:15 +0000</pubDate>
      <link>https://dev.to/forthegeeks/exploring-interesting-javascript-operators-5989</link>
      <guid>https://dev.to/forthegeeks/exploring-interesting-javascript-operators-5989</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;JavaScript is full of operators that, once understood, can greatly simplify your day-to-day coding tasks. In this blog, I’ll focus on a few fascinating operators that may seem simple but are incredibly powerful when applied effectively.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;1. Truthy vs. Falsy Values&lt;/strong&gt;&lt;br&gt;
✍ Before getting into operators, it’s crucial to understand the concept of truthy and falsy values. Hope the below diagram just be enough to get the hold of it&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%2Fdro67dderamkai6bg5hl.png" 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%2Fdro67dderamkai6bg5hl.png" alt="Truthy vs Falsy" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;✅ Falsy Values&lt;/p&gt;

&lt;p&gt;The following values are considered falsy in JavaScript:&lt;br&gt;
false, 0, -0, 0n (BigInt zero), '' (empty string), null, undefined, and NaN.&lt;/p&gt;

&lt;p&gt;✅ Truthy Values — Everything else is truthy, including:&lt;br&gt;
'0', 'false', &lt;a href="https://dev.toempty%20array"&gt;&lt;/a&gt;, {} (empty object), and function() {}.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// FALSY - All below prints false
//const val = 0;
//const val = false;
//const val = -0;
//const val = "";
//const val = ``;
//const val = null;
//const val = undefined;
//const val = NaN;

//TRUTHY
//const val = true;
//const val = "0";
//const val = `''`;
//const val = [];
//const val = {};
//const val = () =&amp;gt; {};

if (val) {
  console.log("truthy");
} else {
  console.log("false");
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. || vs ??: The Difference&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✍ At first glance, below 2 operators may seem similar, as they sometimes produce the same results. But they differ in an important way:&lt;/p&gt;

&lt;p&gt;✅logical OR (||) and&lt;/p&gt;

&lt;p&gt;✅Nullish coalescing (??)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Difference&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;|| : Uses the right-hand value if the left is falsy.&lt;/li&gt;
&lt;li&gt;??: Uses the right-hand value if the left is null OR undefined.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(0 || 'happy', 0 ?? 'happy');        // happy, 0
console.log(false || 'happy', false ?? 'happy'); // happy, false
console.log(undefined || 'happy', undefined ?? 'happy'); // happy, happy
console.log(null || 'happy', null ?? 'happy');   // happy, happy
console.log(NaN || 'happy', NaN ?? 'happy');     // happy, NaN
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Nullish Coalescing Assignment (??=)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✍ This operator combines ?? with the assignment operator =. It assigns a value to a variable only if the variable is null or undefined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let value;
value ??= 'default'; // value becomes 'default' because it was undefined

let anotherValue = 0;
anotherValue ??= 42; // anotherValue remains 0 because it is NOT null OR
                     // undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Optional Chaining (?.)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✍ The optional chaining operator (?.) allows you to safely access deeply nested object properties without worrying about null or undefined. If any part of the chain is null or undefined, it short-circuits and returns undefined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const user = {
  name: 'Manju',
  location: 'AU',
};
console.log(user.profile?.email); // undefined (no error)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Pipeline Operator (|&amp;gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;✍ The pipeline operator, inspired by functional programming, is currently in the proposal stage. It makes method chaining and transformations more intuitive by clearly showing the flow of operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const addQuestion = (str) =&amp;gt; str + "?";
const toUpperCase = (str) =&amp;gt; str.toUpperCase();
const customString = (str) =&amp;gt; str.concat("How are you");
const reverseString = (str) =&amp;gt; str.split("").reverse().join("");

const result = "Hey Manju " |&amp;gt; toUpperCase |&amp;gt; customString |&amp;gt; addQuestion;
const reverseResult = result |&amp;gt; reverseString;

console.log(result); // Output: "HEY MANJU How are you?"
console.log(reverseResult); // Output: "?uoy era woH UJNAM YEH"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Setting Up the Pipeline Operator&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since this is still a proposal , you’ll need Babel to use it in your projects. Follow these steps:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅Install Node.js and npm&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-dev @babel/core @babel/cli @babel/preset-env 
@babel/plugin-proposal-pipeline-operator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;✅Configure Babel&lt;/strong&gt;&lt;br&gt;
Add this to your .babelrc file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "plugins": [
    [
      "@babel/plugin-proposal-pipeline-operator",
      {
        "proposal": "minimal"
      }
    ]
  ],
  "presets": [
    "@babel/preset-env"
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;✅Create and Run Your Code&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Write your code in index.js.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use these scripts in package.json:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;"scripts": {&lt;br&gt;
    "build": "babel index.js --out-file compiled.js",&lt;br&gt;
    "start": "node compiled.js"&lt;br&gt;
  }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and then run your code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build //creates "compiled.js" since we have that mentioned in "build" of our scripts
npm start //runs compiled.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once your run the code is when you see the result we saw above&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
console.log(result); // Output: "HEY MANJU How are you?"
console.log(reverseResult); // Output: "?uoy era woH UJNAM YEH"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;: &lt;a href="https://github.com/tc39/proposal-pipeline-operator" rel="noopener noreferrer"&gt;Pipeline Operator&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Understanding these operators can help you write cleaner and more efficient JavaScript code. Whether it’s the subtle difference between || and ??, safely accessing nested properties with ?., or using the expressive pipeline operator, these tools are invaluable in modern JavaScript development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect with Me&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you enjoyed this post and would like to stay updated with more content like this, feel free to connect with me on social media:&lt;/p&gt;

&lt;p&gt;▶️YouTube :&lt;a href="https://www.youtube.com/c/ForTheGeeks?sub_confirmation=1" rel="noopener noreferrer"&gt; Subscribe to my YouTube Channel&lt;/a&gt; for video tutorials and tons of videos on various subjects&lt;/p&gt;

&lt;p&gt;Medium : &lt;a href="https://medium.com/@vnmshenoy" rel="noopener noreferrer"&gt;Follow me on Medium&lt;/a&gt; where I share more technical articles and insights.&lt;/p&gt;

&lt;p&gt;Blog : &lt;a href="https://www.manjustechblog.com/" rel="noopener noreferrer"&gt;My Personal Blog Website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Email: Email me on &lt;a href="mailto:techspacedeck@gmail.com"&gt;techspacedeck@gmail.com&lt;/a&gt; for any questions, comments, or just to say hi!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Understanding Vue.js Slots: A Toddler Analogy</title>
      <dc:creator>Manjunath Shenoy</dc:creator>
      <pubDate>Fri, 15 Nov 2024 03:01:42 +0000</pubDate>
      <link>https://dev.to/forthegeeks/understanding-vuejs-slots-a-toddler-analogy-547m</link>
      <guid>https://dev.to/forthegeeks/understanding-vuejs-slots-a-toddler-analogy-547m</guid>
      <description>&lt;p&gt;While the official documentation on v-slot is comprehensive, I wanted to share a more relatable analogy to help beginners grasp the concept of slots in Vue.js. Please find below the GitHub source code of the egamples am discussing below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/manjusa/vueLearning_tryout/tree/main/slot-learning" rel="noopener noreferrer"&gt;GitHub source code&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Think of slots as a toddler in a parent-child relationship. Just like a parent guides a toddler on how to dress, slots allow a parent component to dictate what content a child component should display.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;The Toddler Analogy&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Slot as a Toddler: When you see a &lt;strong&gt;&lt;code&gt;&amp;lt;slot&amp;gt;&lt;/code&gt;&lt;/strong&gt;, think of it as a &lt;strong&gt;"slot outlet"&lt;/strong&gt; or a &lt;strong&gt;placeholder&lt;/strong&gt;. It's like a toddler waiting for instructions on what to wear.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Parent's Role: The parent component decides the content, akin to a parent choosing the toddler's outfit. This is known as &lt;strong&gt;"slot content"&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using template Tags: The parent uses &lt;strong&gt;&lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt;&lt;/strong&gt; tags to specify what content goes where, much like a parent organizing a toddler's wardrobe.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;br&gt;
Feel free to keep a printout of this source code excerpt handy ( below image) for quick reference&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%2Fbwkoxpmia2drf57ssle0.png" 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%2Fbwkoxpmia2drf57ssle0.png" alt="Slot-egamples-in-a-nutshell" width="800" height="1010"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1: Conditional Button Display&lt;/strong&gt;&lt;br&gt;
In ParentComponentEg1, the parent component uses a randomNum reference variable to decide which button to display in ChildComponentEg1. Depending on the random number, the parent passes either a “Success” button or a “Try Again” button to the child component, which simply has a slot outlet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt; (based on randomNum ref)&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%2Fw5ggl0bxfz525erq04e6.png" 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%2Fw5ggl0bxfz525erq04e6.png" alt="Result eg 1" width="204" height="111"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;OR&lt;/strong&gt;&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%2Fcwj48mmhu3xs7wmhb24v.png" 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%2Fcwj48mmhu3xs7wmhb24v.png" alt="displays Success button" width="217" height="106"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2: Multiple Slot Outlets&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In ParentComponentEg2, the child component has three slot outlets: header, main, and footer. Imagine the child saying, “I need something for my head, body, and feet.” The parent component specifies what content goes into each slot.&lt;/p&gt;

&lt;p&gt;Simplified Syntax: Instead of using &lt;strong&gt;&lt;code&gt;&amp;lt;template v-slot:slotName&amp;gt;&lt;/code&gt;&lt;/strong&gt;, you can use the shorthand &lt;strong&gt;&lt;code&gt;&amp;lt;template #slotName&amp;gt;&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Result&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%2F886e7kgq5lqx5hi2j68y.png" 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%2F886e7kgq5lqx5hi2j68y.png" alt="Eg2 Result screen" width="300" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 3: Dynamic Slot Names&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this example, slot names are &lt;strong&gt;dynamic&lt;/strong&gt;, driven by variables like “top” and “footwear.” You can access these dynamic properties using either &lt;strong&gt;#[{variable_name}] OR v-slot:[{variable_name}]&lt;/strong&gt;.****&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%2Fn7z0qw19uk8uqj0gacdx.png" 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%2Fn7z0qw19uk8uqj0gacdx.png" alt="Vue Result" width="322" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Note&lt;/strong&gt;&lt;br&gt;
In all these examples, ensure you import the correct ParentComponent into App.vue to see the magic unfold.&lt;/p&gt;

&lt;p&gt;This version aims to make the concept of slots more relatable and memorable, using a simple analogy while keeping the content concise and engaging.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/manjusa/vueLearning_tryout/tree/main/slot-learning" rel="noopener noreferrer"&gt;GitHub source code&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How has this analogy helped you understand Vue.js slots? Do let me know 😃&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect with Me&lt;/strong&gt;&lt;br&gt;
If you enjoyed this post and would like to stay updated with more content like this, feel free to connect with me on social media:&lt;/p&gt;

&lt;p&gt;YouTube : &lt;a href="https://www.youtube.com/c/ForTheGeeks?sub_confirmation=1" rel="noopener noreferrer"&gt;Subscribe to my YouTube Channel&lt;/a&gt; for video tutorials and tons of videos on various subjects&lt;br&gt;
Medium    : &lt;a href="https://medium.com/@vnmshenoy" rel="noopener noreferrer"&gt;Follow me on Medium&lt;/a&gt; where I share more technical articles and insights.&lt;br&gt;
Blog      : &lt;a href="https://www.manjustechblog.com" rel="noopener noreferrer"&gt;My Personal Blog Website&lt;/a&gt;&lt;br&gt;
Email: Email me on &lt;a href="mailto:techspacedeck@gmail.com"&gt;techspacedeck@gmail.com&lt;/a&gt; for any questions, comments, or just to say hi!&lt;/p&gt;

</description>
      <category>vue3</category>
      <category>vue</category>
      <category>programming</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Mastering Dates in JavaScript: The Ultimate Guide to Date &amp; Time Handling</title>
      <dc:creator>Manjunath Shenoy</dc:creator>
      <pubDate>Mon, 11 Nov 2024 06:22:42 +0000</pubDate>
      <link>https://dev.to/forthegeeks/mastering-dates-in-javascript-the-ultimate-guide-to-date-time-handling-3l38</link>
      <guid>https://dev.to/forthegeeks/mastering-dates-in-javascript-the-ultimate-guide-to-date-time-handling-3l38</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In this tutorial, we’ll dive into everything you need to know about dates in JavaScript, starting with the basics. I’ll be doing the entire walkthrough on Microsoft Edge, though you can easily follow along on Chrome as well. We’ll also cover some handy tricks to simulate different time zones right from your browser — yes, you can test across time zones directly in your browser! Plus, we’ll address common challenges and questions that newcomers often face along the way.&lt;br&gt;
Rest assured, if you read through this article carefully, you’ll gain a solid understanding of dates. I’ve worked to combine all the essential information here for your benefit. Pay close attention, and consider printing the included image to keep as a handy reference for day-to-day use — I believe it will be a valuable resource!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;2. Understanding Time Standards and Time Zones&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;2.1 UTC (Coordinated Universal Time)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;✅UTC is a standard, universal time zone that serves as a baseline for all other time zones.&lt;/p&gt;

&lt;p&gt;✅ UTC and GMT: Although UTC and GMT show the same time, they’re not exactly the same. GMT is a time zone, while UTC is a time standard.&lt;br&gt;
The differences are minor and don’t typically affect date handling in JavaScript, so we can treat them as equivalent for most coding purposes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;2.2 Relative Time Zones&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;✅ Every other time zone is essentially an offset from UTC. For example, I’m in Australia in the AEDT time zone, which is GMT+11 (or UTC+11). JavaScript works with these offsets to calculate times accurately across zones. Below is a normal Date() object created(uses browser’s time zone) and then same in UTCString format&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Date Formats in JavaScript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;3.1 ISO 8601 format&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;✅ Returns a string Date and Time in ISO 8601 format. The UTC we saw above is a standard that provides a universal time reference, while ISO 8601, on the other hand, is a standardized way to format date and time values to ensure consistency ,clarity in communication and avoid confusion&lt;/p&gt;

&lt;p&gt;✅ To understand why ISO format is required, lets think of a small story&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Three old school friends — Mike in New York, Laurie in London, and Taro in Tokyo — decided it was finally time to plan a reunion. They hadn’t seen each other in years and wanted to lock down a date to catch up in person. After a long call, they agreed Mike would send an email with the details.&lt;br&gt;
Later that night, Mike sent a quick email saying, “Let’s meet on 01/12/2025 at 00:00.”Laurie, in London, saw the email and thought, “Perfect, December 1st! I’ve got almost a full year to plan.” Taro, in Tokyo, also read 01/12/2025 as December 1st, so he marked it in his calendar and went back to his busy schedule.&lt;br&gt;
But Mike had actually meant January 12, and New York typically formats dates as MM/DD/YYYY. On January 10, he messaged both of them: “Can’t wait to see you guys in a couple of days!”&lt;br&gt;
Both Laurie and Taro were shocked. “Wait — January? I thought we were meeting in December!” Laurie panicked as he realized he’d completely misinterpreted the date, and Taro, realizing his own mistake, scrambled to find a last-minute flight.&lt;br&gt;
After the date confusion, the friends agreed to use ISO 8601 format for all future plans, sticking to 2025–01–12T00:00:00Z for clear communication. Thanks to this new rule, their reunion was finally set — no misunderstandings, no panic, just a simple date everyone understood, no matter where they are.&lt;/p&gt;
&lt;/blockquote&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%2Fr746ui9sq6r2bs28258a.png" 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%2Fr746ui9sq6r2bs28258a.png" alt="ISODateFormat" width="800" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;3.2 Locale-Based Format&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;✅ Returns Date object as a string, using locale settings. We can use this to format date in a particular way using locale options.&lt;/p&gt;

&lt;p&gt;✅ Egamples below, see how date output varies based on locales&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Currently in 'London' Location i.e "en-GB" locale
new Date(); // Sun Nov 10 2024 23:34:22 GMT+0000 (Greenwich Mean Time)
new Date().toLocaleDateString();// '10/11/2024'
new Date().toLocaleDateString("en-US"); // '11/10/2024'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Formatting Dates in JavaScript&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;4.1 Formatting Dates with Intl.DateTimeFormat vs toLocaleDateString&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;JavaScript provides two primary methods for locale-based date formatting:&lt;/p&gt;

&lt;p&gt;✅ Intl.DateTimeFormat is a standalone object allowing flexible formatting options for dates and times.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const options = { 
day: "numeric",
month: "long",
year: "numeric" 
};

new Date().toLocaleDateString("en-GB", options); // "10 November 2024"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅toLocaleDateString is a Date method that returns the date as a localized string. Same output as above&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const options = { 
day: "numeric",
month: "long",
year: "numeric" 
};

new Date().toLocaleDateString("en-GB", options); // "10 November 2024"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4.2 Different Date Formats in Practice&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅We have toUTCString() for UTC dates , toISOString() for ISO format, and toLocaleDateString() for date-only format&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;new Date().toUTCString(); // e.g., 'Sun, 10 Nov 2024 23:51:54 GMT'
new Date().toLocaleString(); // e.g., '10/11/2024, 11:52:13 pm'
new Date().toISOString(); // e.g., '2024-11-10T23:52:24.867Z'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅Date-Only Formats -return only Date&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;new Date().toDateString(); // 'Sun Nov 10 2024'
new Date().toLocaleDateString(); // '10/11/2024'
new Date().toLocaleDateString("en-US"); // '11/10/2024'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Converting and Manipulating Dates&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;5.1 Testing Different Time Zones in Browser- Changing Time Zones Using Sensors&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;✅We already saw above that when you print new Date() on browser, you get date based on Timezone your browser is in. Mine is AEDT so you get AEDT timezone. But what if you want to test out different timezone. That's where “Sensors” come to rescue. I use edge browser in all of egamples below but you can use Chrome too.&lt;/p&gt;

&lt;p&gt;✅Dev Tools → Sensors → Choose Timezone. For eg you can choose "Location" as "London" and you will see that browser runs in Greenwich Mean Time (GMT) though am based in Australia (AEDT).Observe above how time adjustments affect date outputs in JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;5.2 Changing Date Display Formats — Convert a date formatted with spaces or slashes to one separated by hyphens?&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;new Date().toLocaleDateString() // '10/11/2024'
new Date().toLocaleDateString().replace(/\//g,'-') // '10-11-2024'

// If date was in '10 Nov 2024' format, with space instead of /, use below
new Date().toLocaleString("en-GB",options).replace("/ /g","-") //'10-Nov-2024'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;5.3 Using getTime() to Retrieve Epoch Time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can retrieve Epoch time from new Date().getTime() function OR using Date.now()&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(new Date().getTime()+ " ~~ " + Date.now())
//1731283520279 ~~ 1731283520279
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Advanced Date Handling Tips&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;6.1 Using new Date() vs Date()&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When called with new, Date returns a Date object.&lt;br&gt;
When called without new, it returns a string representation of the current date and time.&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%2F3o5u8p3ef2hd61re3a9i.png" 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%2F3o5u8p3ef2hd61re3a9i.png" alt="Date Constructor Options" width="800" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;6.2 Additional Locale Options for Date Formatting&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1) const options = {
  day: "numeric",
  month: "short", //can also be long
  year: "numeric",
};
new Date().toLocaleString("en-GB",options);  //'9 Nov 2024'

2) const options = {
  day: "numeric",
  month: "short", //can also be long
  year: "numeric",
};
new Date().toLocaleString("en-GB",options);  //'9 November 2024'

3) //To display time, need to pass any time-related properties

const options = {
  day: "numeric",
  month: "short",
  year: "numeric",
  hour: "numeric",    // Add this to display the hour
  minute: "numeric",  // Add this to display the minute
  hour12: true        // Keeps time in 12-hour format
};

new Date().toLocaleString("en-GB",options)//'9 Nov 2024, 3:48 pm'
//3a) if hour12 was set to false, prints '9 Nov 2024, 15:38'
//3b) if year was set to 2-digit(instead of numeric') prints 
//    '10 Nov 24, 3:48 pm'

4) /* "day" option above,like year can also be "2-digit" or "numeric"
 - "numeric" - Displays the day as a number WITHOUT zero-padding 
               for single-digit days
 - "2-digit"- Will apply zero-padding for single-digit days
   */

 // Lets see numeric eg

const dayNumericOptions={
  day: "numeric",
  month: "short",
  year: "numeric"
}
//create a date with single digit day
new Date(2024,11,9).toLocaleString("en-GB",dayNumericOptions)//'9 Dec 2024'
// while if you passed "2-digit" to day and ran above prints '09 Dec 2024'

5) // Same way "minute" can be "numeric" or "2-digit".
   //Assume time is 3:05 pm and with "2-digit" option it will print "15:05"
   //while with numeric it will print "15:5"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;6.3 Creating Date Objects with Various Parameters&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The Date constructor in JavaScript is flexible. It can accept 0 or &amp;gt; arguments → providing a range of ways to create Date objects&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%2Fv7yxq1xraqv3mqgnrz0o.png" 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%2Fv7yxq1xraqv3mqgnrz0o.png" alt="Date Construction Options" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Handling dates in JavaScript is challenging due to varying time zones and formats. This article should help you cover everything you need to know about JavaScript date handling, from understanding UTC,ISO 8601 and locale time formats. Keep the reference image and code handy for quick access to date formatting options in your projects!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References — w3schools.com&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Connect with Me&lt;/strong&gt;&lt;br&gt;
If you enjoyed this post and would like to stay updated with more content like this, feel free to connect with me on social media:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;YouTube&lt;/strong&gt;: &lt;a href="https://www.youtube.com/c/ForTheGeeks?sub_confirmation=1" rel="noopener noreferrer"&gt;Subscribe to my YouTube Channel&lt;/a&gt; for video tutorials and tons of videos on various subjects&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Medium&lt;/strong&gt;: &lt;a href="https://medium.com/@vnmshenoy" rel="noopener noreferrer"&gt;Connect on Medium&lt;/a&gt; for blogs on various topic&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Personal Website&lt;/strong&gt;: &lt;a href="https://www.manjustechblog.com" rel="noopener noreferrer"&gt;My Website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Email&lt;/strong&gt;: Email me on &lt;strong&gt;&lt;a href="mailto:techspacedeck@gmail.com"&gt;techspacedeck@gmail.com&lt;/a&gt;&lt;/strong&gt; for any questions, comments, or just to say hi!&lt;br&gt;
I appreciate your support and look forward to connecting with you! Happy coding! And Please do not forget to clap 👏&lt;/p&gt;

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