<?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: P Mukila</title>
    <description>The latest articles on DEV Community by P Mukila (@mukilaperiyasamy).</description>
    <link>https://dev.to/mukilaperiyasamy</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%2F3213025%2F586d8a1b-f188-44a9-9a06-77e63fffe2a5.png</url>
      <title>DEV Community: P Mukila</title>
      <link>https://dev.to/mukilaperiyasamy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mukilaperiyasamy"/>
    <language>en</language>
    <item>
      <title>Java Core Concepts...</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Thu, 31 Jul 2025 13:04:00 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/java-core-concepts-2f87</link>
      <guid>https://dev.to/mukilaperiyasamy/java-core-concepts-2f87</guid>
      <description>&lt;p&gt;&lt;strong&gt;1.Class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A class is a user-defined blueprint or prototype from which objects are created. It contains fields (variables) and methods to define the behavior of objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; &lt;br&gt;
Classes provide a structured way to group related data and behavior. It promotes reusability and modularity in code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car {
    String color;
    void drive() {
        System.out.println("Car is driving");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2.Global and Local Variables&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Global Variable (Instance Variable): Declared inside the class but outside any method. Accessible to all methods of the class.&lt;/p&gt;

&lt;p&gt;Local Variable: Declared inside a method or block. Limited scope to that block.&lt;/p&gt;

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

&lt;p&gt;Global variables maintain object state.&lt;/p&gt;

&lt;p&gt;Local variables support temporary operations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Test {
    int globalVar = 10;
    void show() {
        int localVar = 5;
        System.out.println(globalVar + localVar);
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3.Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Specify the type of data a variable can hold.&lt;/p&gt;

&lt;p&gt;Primitive: byte, short, int, long, float, double, char, boolean.&lt;/p&gt;

&lt;p&gt;Non-Primitive: String, Array, Class, Interface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt;&lt;br&gt;
To define memory size and the type of operation allowed on the data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int age = 25;
float weight = 68.5f;
char grade = 'A';
boolean isValid = true;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4.Package&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A package is a namespace that organizes a set of related classes and interfaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; &lt;br&gt;
Avoids name conflicts and helps manage classes efficiently.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package mypackage;
import java.util.Scanner;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5.Object&lt;/strong&gt;&lt;br&gt;
 An object is an instance of a class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; To access the fields and methods defined in the class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Car myCar = new Car();
myCar.drive();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6.Constructor&lt;/strong&gt;&lt;br&gt;
 A special method that initializes objects. It has the same name as the class and no return type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; To set initial values for object fields.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Bike {
    Bike() {
        System.out.println("Bike created");
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;7.Constructor Chaining&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Calling one constructor from another in the same class using this() or from superclass using super().&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Reuse code and ensure consistent initialization.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car {
    Car() {
        this(100);
        System.out.println("Default constructor");
    }
    Car(int speed) {
        System.out.println("Speed: " + speed);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;8.Inheritance&lt;/strong&gt;&lt;br&gt;
 Mechanism where a new class acquires the properties and behaviors of a parent class using extends.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Code reuse and hierarchical classification.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Animal {
    void eat() {
        System.out.println("Eating...");
    }
}
class Dog extends Animal {
    void bark() {
        System.out.println("Barking...");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;9.Abstraction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hiding implementation details and showing only the functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Increases code security and reduces complexity.&lt;br&gt;
Using abstract class or interface.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;abstract class Shape {
    abstract void draw();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;10.Polymorphism&lt;/strong&gt;&lt;br&gt;
 Ability of an object to take many forms. Two types: compile-time (method overloading) and run-time (method overriding).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Flexibility and dynamic behavior.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Animal {
    void sound() {
        System.out.println("Animal sound");
    }
}
class Dog extends Animal {
    void sound() {
        System.out.println("Dog barks");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;11.Encapsulation&lt;/strong&gt;&lt;br&gt;
 Binding data (variables) and methods into a single unit (class).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Protects data from outside interference and supports data hiding.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Person {
    private int age;
    public void setAge(int a) { age = a; }
    public int getAge() { return age; }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;12.Interface&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A reference type in Java, similar to a class, that can contain only abstract methods (Java 8+ allows default/static methods).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; To achieve full abstraction and multiple inheritance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Animal {
    void eat();
}
class Dog implements Animal {
    public void eat() {
        System.out.println("Dog eats");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;13.this vs super&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;this: Refers to the current class object.&lt;/p&gt;

&lt;p&gt;super: Refers to the immediate parent class object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Resolve naming conflicts, call parent class methods or constructors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class A {
    int x = 10;
}
class B extends A {
    int x = 20;
    void display() {
        System.out.println(this.x);  // 20
        System.out.println(super.x); // 10
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;14.this() vs super()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;this(): Calls a constructor in the same class.&lt;/p&gt;

&lt;p&gt;super(): Calls a constructor in the parent class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Constructor reuse and initialization.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Parent {
    Parent() {
        System.out.println("Parent constructor");
    }
}
class Child extends Parent {
    Child() {
        super();
        System.out.println("Child constructor");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;15.final Keyword&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Used to make a variable constant, prevent method overriding, or inheritance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; Enforce immutability and restriction.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final int x = 100; // can't be changed
final void show() {} // can't be overridden
final class A {} // can't be extended
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;16.static vs non-static&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;static: Belongs to class, not object. Shared across all instances.&lt;/p&gt;

&lt;p&gt;non-static: Belongs to individual objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why:&lt;/strong&gt; To share common data or methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
class Demo {
    static int count = 0;
    int id;
    Demo(int id) {
        this.id = id;
        count++;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>classandobject</category>
      <category>interface</category>
      <category>methodoverloadingandoverriding</category>
      <category>constructor</category>
    </item>
    <item>
      <title>Introduction to Java</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Thu, 10 Jul 2025 17:49:21 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/introduction-to-java-4f52</link>
      <guid>https://dev.to/mukilaperiyasamy/introduction-to-java-4f52</guid>
      <description>&lt;p&gt;&lt;strong&gt;Java&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Java is a popular programming language.&lt;/li&gt;
&lt;li&gt;Java is used to develop mobile apps, web apps, desktop apps, games and much more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Features of Java:&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;Platform Independence

Simple and Familiar

Multithreading

High Performance

Portable

Object Oriented

Robust and Secure

Dynamic

Distributed


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Platform Independence:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java is bytecode can be executed on any platform with the appropriate JVM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Object Oriented:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java follows the object-oriented programming paredigm, encapsulation, ingeritance,and polymarphism.&lt;/p&gt;

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

&lt;p&gt;Java is syntax is inspired by C++ and C ,making it familiar to may programmers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Robust and Secure:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java has feature like memory management, strong type checking, and&lt;br&gt;
exception handling to ensure robust and secure programs.&lt;/p&gt;

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

&lt;p&gt;Java supports multithreading, allowing  multiple tasks to be executed concurrently.&lt;/p&gt;

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

&lt;p&gt;Java supports dynamic memory allocation and garbage collection, simplifying memory management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;High Performance:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While java programs might not be as fast as compiled languages like C++, javas performance has improved over time,thanks to JVM optimizations.&lt;/p&gt;

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

&lt;p&gt;Java "write once,run anywhere"capability makes it highly portable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Architecture of Java:&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%2Fcb654p9c9uij53vslnea.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%2Fcb654p9c9uij53vslnea.png" alt=" " width="665" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compiler&lt;/strong&gt;: Compiler can convert java code to byte code (.java file to .class file) with help of Java development kit(JDK). It translate entire code of the program.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interpreter&lt;/strong&gt;: In Java, an interpreter is a program that executes Java bytecode instructions line by line. It's a key component of the Java Virtual Machine (JVM).&lt;/p&gt;

</description>
      <category>java</category>
      <category>featuresofjava</category>
      <category>architectureofjava</category>
    </item>
    <item>
      <title>JavaScript String Methods</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Thu, 03 Jul 2025 18:49:05 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/javascript-string-methods-55k6</link>
      <guid>https://dev.to/mukilaperiyasamy/javascript-string-methods-55k6</guid>
      <description>&lt;p&gt;Javascript strings are primitive and immutable: All string methods produce a new string without altering the original string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Converting to Upper and Lower Case&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A string is converted to upper case with toUpperCase():&lt;/p&gt;

&lt;p&gt;A string is converted to lower case with toLowerCase():&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;toUpperCase():&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;h1&amp;gt;JavaScript String Methods&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;Convert string to upper case:&amp;lt;/p&amp;gt;

&amp;lt;button onclick="myFunction()"&amp;gt;Try it&amp;lt;/button&amp;gt;

&amp;lt;p id="demo"&amp;gt;Hello World!&amp;lt;/p&amp;gt;

&amp;lt;script&amp;gt;
function myFunction() {
  let text = document.getElementById("demo").innerHTML;
  document.getElementById("demo").innerHTML =
  text.toUpperCase();
}
&amp;lt;/script&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;toLowerCase():&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;string to Lowercase
   &amp;lt;h1&amp;gt;String Lowercase&amp;lt;/h1&amp;gt; 
   &amp;lt;p&amp;gt;Convert string to lower case:&amp;lt;/p&amp;gt;
   &amp;lt;button onclick="myFunction()"&amp;gt;Try it&amp;lt;/button&amp;gt;
   &amp;lt;p id="demo"&amp;gt;Hello World&amp;lt;/p&amp;gt;
   &amp;lt;script&amp;gt;
   function myFunction(){
   let text = document.getElementById("demo").innerHTML;
   document.getElementById("demo").innerHTML =          text.toLowerCase();
     }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;JavaScript String concat():&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;concat() joins two or more strings&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;String concat&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;concat() joins two or more strings:&amp;lt;/p&amp;gt;
&amp;lt;p id="click"&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;script&amp;gt;
    let text1 = "Hello";
    let text2 = "World!";
    let text3 = text1.concat(" ",text2);
    document.getElementById("click").innerHTML = text3;


&amp;lt;/script&amp;gt; 



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;JavaScript String trimStart():&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The trimStart() method works like trim(), but removes whitespace only from the start of a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Trimstart javascript&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;The trimStart() method works like trim(), but removes whitespace only from the start of a string.
&amp;lt;/p&amp;gt;
&amp;lt;p id="change"&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;script&amp;gt;
    let text1 = "     Hello    World"
    let text2 = text1.trimStart();
    document.getElementById("change").innerText = 

    "Length.text1 = " + text1.length + "&amp;lt;br&amp;gt;Length.text2 = " + text2.length;

&amp;lt;/script&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;JavaScript String trimEnd()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The trimEnd() method works like trim(), but removes whitespace only from the end of a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt; trimend javascript&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;The trimEnd() method works like trim(), but removes whitespace only from the end of a string.&amp;lt;/p&amp;gt;
&amp;lt;p id="change"&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;script&amp;gt;
    let text1 = "     Hello World             ";
    let text2 = text1.trimEnd();
    document.getElementById("change").innerHTML = 
    "Length.text1 = "+ text1.length + "&amp;lt;br&amp;gt;length.text2 = " + text2.length; 
 &amp;lt;/script&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;JavaScript String padStart():&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The padStart() method pads a string from the start.&lt;/p&gt;

&lt;p&gt;It pads a string with another string (multiple times) until it reaches a given length.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;string padstart&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;The padStart() method pads a string from the start.&amp;lt;/p&amp;gt;
    &amp;lt;p id="change"&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;script&amp;gt;
    let element = "6";
    element = element.padStart(4,"0");
    document.getElementById("change").innerHTML =  element;

&amp;lt;/script&amp;gt; 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;JavaScript String padEnd():&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The padEnd() method pads a string from the end.&lt;/p&gt;

&lt;p&gt;It pads a string with another string (multiple times) until it reaches a given length.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;String padend&amp;lt;/h1&amp;gt;
&amp;lt;p&amp;gt;It pads a string with another string (multiple times) until it reaches a given length.&amp;lt;/p&amp;gt;
&amp;lt;p id="click"&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;script&amp;gt;

    let text = "5";
    text = text.padEnd(4,"0");
    document.getElementById("click").innerHTML = text;
&amp;lt;/script&amp;gt;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>lowercaseanduppercase</category>
      <category>trimstart</category>
      <category>padstartandpadend</category>
      <category>concat</category>
    </item>
    <item>
      <title>Today new thing learn from Linux Commands...</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Wed, 02 Jul 2025 17:32:22 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/today-new-thing-learn-from-linux-commands-40cl</link>
      <guid>https://dev.to/mukilaperiyasamy/today-new-thing-learn-from-linux-commands-40cl</guid>
      <description>&lt;p&gt;Today, my classmates presented a PPT on Linux commands. It was very useful, and we learned a lot from the session. Our teaching style was clear and effective.&lt;/p&gt;

&lt;p&gt;They covered many important Linux topics, and our teacher also explained them during the session. For me, there were some commands I didn’t know before, so I kept watching closely to understand better. I already knew a few commands, but I learned even more today.&lt;/p&gt;

&lt;p&gt;They gave examples and explained topics like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Files &amp;amp; Directory Management:&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;
• - ls: List files and directories
• - cd: Change directory
• - pwd: Show current directory path
• - mkdir: Create directory
• - rmdir: Remove empty directory
• - touch: Create empty file
• - cp: Copy files/directories
• - mv: Move/rename files
• - rm: Remove files/directories
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Viewing &amp;amp; Editing Files:&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;• - cat: View file content
• - less/more: Paginate file output
• - head: Show first 10 lines
• - tail: Show last 10 lines (tail -f for live logs)
• - nano/vim: Terminal-based text editors


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;File Permissions:&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;
• - chmod: Change file permissions

• - chown: Change file ownership
• - ls -l: Detailed file info including permissions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Searching Files:&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;
• - find: Locate files (find . -name "file.txt")
• - grep: Search inside files (grep "text" filename)
• - locate: Fast file searching
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Process Management:&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;
• - ps: List running processes
• - top/htop: Monitor processes and resources
• - kill: Terminate process by PID
• - killall: Kill processes by name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Networking:&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;
• - ping: Test network connectivity
• - curl: Access URLs/APIs
• - wget: Download files
• - netstat: Network connections info
• - ssh: Remote server access
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Disk &amp;amp; Space Management:&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;
• - df -h: Show disk usage
• - du -sh: Show directory size
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Package Management(Ubuntu/Debian):&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;
• - apt update: Update package lists
• - apt upgrade: Upgrade packages
• - apt install: Install new packages
• - apt remove: Remove packages
• - tar -czf: Compress files to .tar.gz
• - tar -xzf: Extract .tar.gz files
• - zip/unzip: Handle .zip files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Version Control (Git Basics):&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;
• - git init: Initialize repo
• - git clone: Clone repository
• - git add: Stage changes
• - git commit: Commit changes
• - git push/pull: Push/Pull code
• - git status: Repo status
• - git log: Commit history
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Miscellaneous Useful Commands:&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;
• - echo: Print text
• - history: Show previous commands
• - clear: Clear terminal
• - alias: Set command shortcuts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It was a very informative presentation, and it helped deepen my understanding of Linux commands.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>commends</category>
    </item>
    <item>
      <title>Today i Learned - fetch, async &amp; await, axios...</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Tue, 01 Jul 2025 18:14:17 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/today-i-learned-fetch-async-await-axios-1jgp</link>
      <guid>https://dev.to/mukilaperiyasamy/today-i-learned-fetch-async-await-axios-1jgp</guid>
      <description>&lt;p&gt;&lt;strong&gt;fetch&lt;/strong&gt;&lt;br&gt;
      The fetch() API in JavaScript provides a modern and flexible interface for making network requests, primarily designed to replace the older XMLHttpRequest. It allows you to fetch resources like JSON data, HTML, images, and more from a server. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic Syntax&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;fetch(url, options)
  .then(response =&amp;gt; response.json())
  .then(data =&amp;gt; {
    // Do something with the data
  })
  .catch(error =&amp;gt; {
    // Handle any errors
  });

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Parameters&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;url: The URL to which the request is sent.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;options (optional): An object that allows you to configure the request (method, headers, body, etc.).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;fetch returns a Promise.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It won’t reject on HTTP errors like 404 or 500 — you have to check response.ok.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getWeather() {
             const apiKey = "2a50fd8aa879e6af857307fdc1a16bc6";
             const url = `http://api.openweathermap.org/data/2.5/      weather?q=${city}&amp;amp;appid=${apiKey}&amp;amp;units=metric`;

             fetch(url)
                 .then((res) =&amp;gt; {
                    return res.json();
                 }).then((data) =&amp;gt; {
                     console.log(data.main.feels_like);
                  result.innerHTML = `Temperature : ${data.main.temp}`
              }).catch((error) =&amp;gt; {
                  console.log(error);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;A function declared with async always returns a Promise.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function getData() {
  return "Hello";
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Calling getData() returns a Promise that resolves to "Hello".&lt;br&gt;
&lt;strong&gt;await:&lt;/strong&gt;&lt;br&gt;
You use await inside async functions to pause the code until a Promise is resolved.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function fetchData() {
  let response = await fetch('https://api.example.com/data');
  let data = await response.json();
  console.log(data);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Axios is a promise-based HTTP client for browsers and Node.js. It simplifies making requests to APIs and handling responses.&lt;/p&gt;

&lt;p&gt;Installing Axios:&lt;/p&gt;

&lt;p&gt;Use npm or yarn:&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 axios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or use a CDN in your HTML:&lt;br&gt;
&lt;code&gt;&amp;lt;script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Or with async/await:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async function fetchPosts() {
  try {
    const res = await axios.get('https://api.example.com/posts');
    console.log(res.data);
  } catch (err) {
    console.error('Axios error:', err);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>fetch</category>
      <category>async</category>
      <category>await</category>
      <category>axios</category>
    </item>
    <item>
      <title>Promise in Javascript ...</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Mon, 30 Jun 2025 16:56:25 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/promise-in-javascript--3iec</link>
      <guid>https://dev.to/mukilaperiyasamy/promise-in-javascript--3iec</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Promise?&lt;/strong&gt;&lt;br&gt;
     In JavaScript, a Promise is an object representing the eventual completion or failure of an asynchronous operation. It acts as a placeholder for a value that is not yet known but will be available at some point in the future. Promises provide a structured and cleaner way to handle asynchronous code compared to traditional callback functions, which can lead to "callback hell" in complex scenarios. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Promise can exist in one of three states:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pending: The initial state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fulfilled (or Resolved): The operation completed successfully.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Rejected: The operation failed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Creating a Promise:&lt;/strong&gt;&lt;br&gt;
      A &lt;code&gt;new Promise&lt;/code&gt; is created using the Promise constructor. This executor function receives two arguments: &lt;code&gt;resolve&lt;/code&gt; and&lt;code&gt;reject&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling Results:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.then():&lt;/code&gt; Used to attach callbacks for when the Promise is fulfilled.&lt;br&gt;
&lt;code&gt;.catch():&lt;/code&gt; Used specifically to handle errors (rejections) in a Promise chain.&lt;br&gt;
&lt;strong&gt;syntax:&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 login=new promise((resolve,reject)=&amp;gt;{
let password=true;
if(Password){
  resolve();
}else{
  reject();
}
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;Document&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;script&amp;gt;
        function login(){
            return new Promise((resolve,reject)=&amp;gt;{
                let password=true;
                if(password){
                    resolve();

                }else{
                    reject();
                }

            })
        }
        login()
        .then(()=&amp;gt; console.log("Successfully login..."))
        .catch(()=&amp;gt;console.log("invalid password..."))
    &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>promise</category>
    </item>
    <item>
      <title>React Router</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Fri, 27 Jun 2025 16:54:06 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/react-router-33fp</link>
      <guid>https://dev.to/mukilaperiyasamy/react-router-33fp</guid>
      <description>&lt;p&gt;&lt;strong&gt;Router&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React Router is a standard library for routing in React. It enables navigation among views of various components in a React application, allows the browser URL to reflect the app state, and keeps the UI in sync with the URL.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Routes: Define the mappings between URL paths and React components.

Router: The top-level component that provides routing functionality.

Link: A component to navigate around the application without reloading the page.

useNavigate, useParams, useLocation: React hooks for navigation, accessing URL parameters, and location state.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Installation&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 react-router-dom
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For projects using React Native, use react-router-native.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic 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;import React from 'react';
import {
  BrowserRouter as Router,
  Routes,
  Route,
  Link
} from 'react-router-dom';

function Home() {
  return &amp;lt;h2&amp;gt;Home Page&amp;lt;/h2&amp;gt;;
}

function About() {
  return &amp;lt;h2&amp;gt;About Page&amp;lt;/h2&amp;gt;;
}

function App() {
  return (
    &amp;lt;Router&amp;gt;
      &amp;lt;nav&amp;gt;
        &amp;lt;Link to="/"&amp;gt;Home&amp;lt;/Link&amp;gt; | &amp;lt;Link to="/about"&amp;gt;About&amp;lt;/Link&amp;gt;
      &amp;lt;/nav&amp;gt;
      &amp;lt;Routes&amp;gt;
        &amp;lt;Route path="/" element={&amp;lt;Home /&amp;gt;} /&amp;gt;
        &amp;lt;Route path="/about" element={&amp;lt;About /&amp;gt;} /&amp;gt;
      &amp;lt;/Routes&amp;gt;
    &amp;lt;/Router&amp;gt;
  );
}

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Common Features&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nested Routes: Structure your routes like your UI structure.

Route Parameters: Capture values from the URL (/user/:id).

Redirects: Navigate programmatically or with &amp;lt;Navigate /&amp;gt;.

Lazy Loading: Load components only when needed using React.lazy.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>router</category>
    </item>
    <item>
      <title>Today I learned-Object,this keyword and hoisting in react.js...</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Thu, 19 Jun 2025 17:16:33 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/today-i-learned-objectthis-keyword-and-hoisting-in-reactjs-6dl</link>
      <guid>https://dev.to/mukilaperiyasamy/today-i-learned-objectthis-keyword-and-hoisting-in-reactjs-6dl</guid>
      <description>&lt;p&gt;&lt;strong&gt;1.What is an Object in React.js?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript (and React by extension), an object is a data structure used to store collections of data and more complex entities.&lt;/p&gt;

&lt;p&gt;In React, objects are commonly used for:&lt;br&gt;
Component state:&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, setUser] = useState({ name: "Alice", age: 30 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function Profile(props) {
  return &amp;lt;h1&amp;gt;{props.user.name}&amp;lt;/h1&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Styles (as inline styles):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const style = { color: "red", fontSize: "20px" };
return &amp;lt;div style={style}&amp;gt;Hello&amp;lt;/div&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2.this Keyword in React.js&lt;/strong&gt;&lt;br&gt;
The this keyword refers to the context in which a function is executed.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;In class components, this typically refers to the component instance:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = { count: 0 };
    this.handleClick = this.handleClick.bind(this); // bind `this`
  }

  handleClick() {
    console.log(this.state.count); // `this` refers to the component
  }

  render() {
    return &amp;lt;button onClick={this.handleClick}&amp;gt;Click Me&amp;lt;/button&amp;gt;;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If you don’t bind this, it might be undefined or refer to the wrong context.&lt;/p&gt;

&lt;p&gt;In functional components with hooks, you don’t use this, which is one reason why hooks are popular:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function MyComponent() {
  const [count, setCount] = useState(0);

  const handleClick = () =&amp;gt; {
    console.log(count);
  };

  return &amp;lt;button onClick={handleClick}&amp;gt;Click Me&amp;lt;/button&amp;gt;;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3.Hoisting in React.js&lt;/strong&gt;&lt;br&gt;
Hoisting is a JavaScript concept, not specific to React, but it still affects how you write React code.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;In JavaScript:

    Function declarations are hoisted:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sayHello(); // Works fine

function sayHello() {
  console.log("Hello");
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Variables declared with var are hoisted but not initialized.

let and const are not initialized, leading to a temporal dead zone.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In React, hoisting matters if you:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Define helper functions below your component:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function MyComponent() {
  return &amp;lt;div&amp;gt;{getGreeting()}&amp;lt;/div&amp;gt;;
}

function getGreeting() {
  return "Hello!";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Summary&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Meaning in React&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Object&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Structure for storing and passing data (&lt;code&gt;props&lt;/code&gt;, &lt;code&gt;state&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;this&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Refers to component instance in class components&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Hoisting&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;JS behavior affecting function and variable declaration order; important when defining helper functions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>objectreact</category>
      <category>hoistingreact</category>
      <category>thiskeyword</category>
    </item>
    <item>
      <title>Today I Learn - Understanding Arrays, Spread Operator, map(), and useState in JavaScript and React...</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Mon, 16 Jun 2025 15:13:27 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/today-i-learn-understanding-arrays-spread-operator-map-and-usestate-in-javascript-and-567n</link>
      <guid>https://dev.to/mukilaperiyasamy/today-i-learn-understanding-arrays-spread-operator-map-and-usestate-in-javascript-and-567n</guid>
      <description>&lt;p&gt;When working with JavaScript and React, there are a few core concepts that you’ll use again and again: arrays, the spread operator (...), the map() function, and React's useState hook. In this blog, we’ll break each one down with simple examples so you can understand how and when to use them effectively.&lt;/p&gt;

&lt;h2&gt;
  
  
  Arrays in JavaScript
&lt;/h2&gt;

&lt;p&gt;An array is a list-like object used to store multiple values in a single variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fruits = ['apple', 'banana', 'cherry'];
console.log(fruits[0]); // Output: apple

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Arrays can hold any data type — strings, numbers, objects, or even other arrays.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Spread Operator (...)
&lt;/h2&gt;

&lt;p&gt;The spread operator allows you to quickly copy or merge arrays and objects.&lt;br&gt;
Copying an array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const original = [1, 2, 3];
const copy = [...original];

console.log(copy); // [1, 2, 3]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Adding elements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3];
const moreNumbers = [...numbers, 4, 5];

console.log(moreNumbers); // [1, 2, 3, 4, 5]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Merging arrays:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const a = [1, 2];
const b = [3, 4];
const combined = [...a, ...b];

console.log(combined); // [1, 2, 3, 4]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using map() to Transform Arrays
&lt;/h2&gt;

&lt;p&gt;The map() method lets you apply a function to every element in an array and returns a new array.&lt;br&gt;
Example: Multiply each number by 2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3];
const doubled = numbers.map(num =&amp;gt; num * 2);

console.log(doubled); // [2, 4, 6]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In React, map() is commonly used to render lists of components:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const items = ['pen', 'notebook', 'eraser'];

return (
  &amp;lt;ul&amp;gt;
    {items.map((item, index) =&amp;gt; &amp;lt;li key={index}&amp;gt;{item}&amp;lt;/li&amp;gt;)}
  &amp;lt;/ul&amp;gt;
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  useState in React
&lt;/h2&gt;

&lt;p&gt;React's useState hook lets you add state to functional components.&lt;br&gt;
Basic usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from 'react';

function Counter() {
  const [count, setCount] = useState(0);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;p&amp;gt;Count: {count}&amp;lt;/p&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCount(count + 1)}&amp;gt;Increase&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Updating an array with useState and the spread operator:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function TodoList() {
  const [todos, setTodos] = useState(['Buy milk']);

  const addTodo = () =&amp;gt; {
    setTodos([...todos, 'Walk the dog']);
  };

  return (
    &amp;lt;&amp;gt;
      &amp;lt;ul&amp;gt;
        {todos.map((todo, index) =&amp;gt; &amp;lt;li key={index}&amp;gt;{todo}&amp;lt;/li&amp;gt;)}
      &amp;lt;/ul&amp;gt;
      &amp;lt;button onClick={addTodo}&amp;gt;Add Todo&amp;lt;/button&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>spreadoperator</category>
      <category>arrayfunction</category>
      <category>map</category>
      <category>usestate</category>
    </item>
    <item>
      <title>I Learned Today- Basics of React ...</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Fri, 13 Jun 2025 10:06:45 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/i-learned-today-basics-of-react--1kp8</link>
      <guid>https://dev.to/mukilaperiyasamy/i-learned-today-basics-of-react--1kp8</guid>
      <description>&lt;p&gt;It looks like you're asking about npm, npx, and how they relate to React development. Here's a quick breakdown of each term and how they work together:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Npm (Node Package Manager)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;npm is the default package manager for Node.js.&lt;/li&gt;
&lt;li&gt;    You use it to install packages (like React) and manage dependencies in your project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples:&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 react react-dom

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Installs React and ReactDOM into your project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;npx (npm execute)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;npx comes with npm (version 5.2+).&lt;/li&gt;
&lt;li&gt;    It's used to run packages without installing them globally.&lt;/li&gt;
&lt;li&gt;    Very useful for tools like create-react-app.
&lt;strong&gt;Example:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This runs the create-react-app package to set up a new React project called my-app — no need to install it globally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Typical Workflow for React&lt;/strong&gt;&lt;br&gt;
1.Create a new React app using npx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-app
cd my-app

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Start the development server:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;3.Install additional dependencies (if needed):&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 axios  # for HTTP requests
npm install react-router-dom  # for routing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What is JSX?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JSX is a syntax extension to JavaScript. It lets you write HTML-like code inside JavaScript — commonly used in React.&lt;br&gt;
&lt;strong&gt;JSX Example (React)&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 element = &amp;lt;h1&amp;gt;Hello, world!&amp;lt;/h1&amp;gt;;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This looks like HTML, but it’s actually JavaScript with JSX syntax.&lt;/li&gt;
&lt;li&gt;    It gets converted to regular JavaScript before running.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;JavaScript is the core programming language used to add behavior to web pages. JSX is built on top of JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JS 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 name = "World";
const message = "Hello, " + name + "!";

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How They Work Together in React&lt;/strong&gt;&lt;br&gt;
JSX + JS Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const name = "React";
const element = &amp;lt;h1&amp;gt;Hello, {name}!&amp;lt;/h1&amp;gt;;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`JSX: &amp;lt;h1&amp;gt;Hello, {name}!&amp;lt;/h1&amp;gt;
JS: const name = "React"; (inside JSX {})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;JS and JSX are used together: JS handles logic, JSX handles UI.&lt;br&gt;
`&lt;br&gt;
&lt;strong&gt;JSX Compiles to JS&lt;/strong&gt;&lt;/p&gt;

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

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

const element = &amp;lt;h1&amp;gt;Hello&amp;lt;/h1&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compiles to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const element = React.createElement('h1', null, 'Hello');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Framework or Library
&lt;/h2&gt;

&lt;p&gt;React is a JavaScript library, not a framework. It is used to build user interfaces (UIs) by creating reusable components. While React provides a foundation for building UIs, it doesn't dictate how to structure an entire application, making it flexible and adaptable. &lt;/p&gt;

&lt;p&gt;Library&lt;/p&gt;

&lt;p&gt;A library is a collection of pre-written code components like functions, classes, and modules that streamline development tasks by providing reusable functionality.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It only handles the view layer (UI) of your app.&lt;/li&gt;
&lt;li&gt;It doesn’t include built-in solutions for routing, state management, or form handling.&lt;/li&gt;
&lt;li&gt;You’re in charge of how to structure your app and what other tools to use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Framework&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;While React itself is a library, there are frameworks built on top of React to provide structure and features that React alone doesn’t include.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Hooks in React?
&lt;/h2&gt;

&lt;p&gt;React Hooks were introduced to simplify and modernize how we write React components. They solve real problems that existed with class components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Top Reasons for Using Hooks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.Simplify Components&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hooks allow you to use state and lifecycle methods without classes.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyComponent extends React.Component {
  state = { count: 0 };
  // lifecycle methods...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function MyComponent() {
  const [count, setCount] = useState(0);
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2.Avoid Repetition&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With class components, logic often had to be duplicated or split across lifecycle methods. Hooks let you group related logic together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.Better Reusability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Custom hooks let you extract and reuse logic across components — much cleaner than using Higher-Order Components (HOCs) or Render Props.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function useOnlineStatus() {
  const [isOnline, setIsOnline] = useState(true);
  // logic here...
  return isOnline;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4.Cleaner Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hooks reduce boilerplate and make functional components easier to read and test.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.Eliminate Confusion with &lt;code&gt;this&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In class components, this can be confusing. Hooks don’t use this, which avoids common bugs and improves clarity.&lt;/p&gt;

</description>
      <category>npm</category>
      <category>jsxvsjs</category>
      <category>frameworkandlibrary</category>
      <category>hookinreact</category>
    </item>
    <item>
      <title>I learned introduction of React...</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Thu, 12 Jun 2025 16:06:32 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/i-learned-introduction-of-react-n1o</link>
      <guid>https://dev.to/mukilaperiyasamy/i-learned-introduction-of-react-n1o</guid>
      <description>&lt;p&gt;Sure! Here’s a clear and concise explanation of React, SPA, MPA, and the difference between ReactDOM and JS DOM:&lt;/p&gt;

&lt;h2&gt;
  
  
  What is React
&lt;/h2&gt;

&lt;p&gt;ReactJS is a component-based JavaScript library used to build dynamic and interactive user interfaces. It simplifies the creation of single-page applications (SPAs) with a focus on performance and maintainability.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is developed and maintained by Facebook.&lt;/li&gt;
&lt;li&gt;    The latest version of React is React 19.&lt;/li&gt;
&lt;li&gt;    Uses a virtual DOM for faster updates.&lt;/li&gt;
&lt;li&gt;    Supports a declarative approach to designing UI components.&lt;/li&gt;
&lt;li&gt;    Ensures better application control with one-way data binding.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SPA (Single Page Application)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An SPA is a web app that loads one HTML page and dynamically updates the content as the user interacts with the app, without refreshing the entire page. React is often used to build SPAs because it efficiently updates the UI on the client side.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MPA (Multi Page Application)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An MPA consists of multiple separate HTML pages. Every time a user clicks a link, the browser loads a new page from the server, causing a full page refresh.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;     Each page is a separate HTML file.
     Full reload on navigation.
     Better for SEO and simple websites.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;React Components&lt;/strong&gt;&lt;br&gt;
A React component is a reusable piece of code that defines a part of the user interface. It accepts inputs called props and returns JSX to describe what should be displayed on the screen. Components help build and organize UI in a modular way.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Components are building blocks of a React app.&lt;/li&gt;
&lt;li&gt;    They are reusable pieces of UI, like buttons, headers, or entire pages.&lt;/li&gt;
&lt;li&gt;    Components can be written as functions or classes (functional components are more common now).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Return Function in Components&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; A React functional component is basically a function that returns JSX.&lt;/li&gt;
&lt;li&gt;    JSX looks like HTML but is actually JavaScript that tells React what to render.&lt;/li&gt;
&lt;li&gt;    The value you return from the component is what appears on the screen.
Example:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;function Greeting() {&lt;br&gt;
  return &amp;lt;h1&amp;gt;Hello, world!&amp;lt;/h1&amp;gt;;  // This JSX will be rendered in the UI&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    Here, the Greeting component returns an &amp;lt;h1&amp;gt; element.
    React takes that and displays "Hello, world!" on the webpage.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>react</category>
      <category>mpa</category>
      <category>component</category>
      <category>returefunction</category>
    </item>
    <item>
      <title>Today I learned-JavaScript: while Loops, Arrow Functions, and the map() Method</title>
      <dc:creator>P Mukila</dc:creator>
      <pubDate>Mon, 09 Jun 2025 14:32:20 +0000</pubDate>
      <link>https://dev.to/mukilaperiyasamy/today-i-learned-javascript-while-loops-arrow-functions-and-the-map-method-41d1</link>
      <guid>https://dev.to/mukilaperiyasamy/today-i-learned-javascript-while-loops-arrow-functions-and-the-map-method-41d1</guid>
      <description>&lt;h2&gt;
  
  
  1.Looping with while
&lt;/h2&gt;

&lt;p&gt;The while loop continues executing a block of code as long as a condition is true.&lt;/p&gt;

&lt;h2&gt;
  
  
  Syntax:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let i = 0;
while (i &amp;lt; 5) {
  console.log(i);
  i++;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notes:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Be careful to increment the counter (i++), or you might create an infinite loop.

Use while when you don't know ahead of time how many times you'll loop.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  2.Arrow Functions
&lt;/h2&gt;

&lt;p&gt;Arrow functions are a shorter syntax for writing functions. They're especially useful for small functions or callbacks.&lt;br&gt;
 Syntax:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Regular function
function add(a, b) {
  return a + b;
}

// Arrow function
const add = (a, b) =&amp;gt; a + b;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key Features:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Short and clean syntax.

Does not have its own this (inherits from parent scope).

Great for array methods like map, filter, forEach, etc.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  3.map() Method
&lt;/h2&gt;

&lt;p&gt;The map() method creates a new array by applying a function to each element in an existing array.&lt;br&gt;
 Syntax:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const numbers = [1, 2, 3];
const doubled = numbers.map(num =&amp;gt; num * 2);
console.log(doubled); // [2, 4, 6]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notes:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;map() does not modify the original array.

The returned array will have the same length as the original.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Example: Combining All Three&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let nums = [1, 2, 3, 4, 5];
let i = 0;

while (i &amp;lt; nums.length) {
  nums[i] += 1;
  i++;
}

const doubled = nums.map(n =&amp;gt; n * 2);
console.log(doubled); // [4, 6, 8, 10, 12]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
