<?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: WebTechnology Tutorials</title>
    <description>The latest articles on DEV Community by WebTechnology Tutorials (@webtechnology_tutorials_f).</description>
    <link>https://dev.to/webtechnology_tutorials_f</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%2F3278983%2Fec03fbe9-679b-4e1b-866f-965fbcebdc70.png</url>
      <title>DEV Community: WebTechnology Tutorials</title>
      <link>https://dev.to/webtechnology_tutorials_f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/webtechnology_tutorials_f"/>
    <language>en</language>
    <item>
      <title>Logical Operators in JavaScript – Complete Guide with Real Examples</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Fri, 11 Jul 2025 07:20:46 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/logical-operators-in-javascript-complete-guide-with-real-examples-1ej6</link>
      <guid>https://dev.to/webtechnology_tutorials_f/logical-operators-in-javascript-complete-guide-with-real-examples-1ej6</guid>
      <description>&lt;p&gt;&lt;em&gt;Learn how &amp;amp;&amp;amp;, ||, and ! work in JavaScript. Understand truthy/falsy, real-world usage, short-circuiting, and more with easy examples.&lt;/em&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%2F1u2ipvub6kbm3dqzliao.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%2F1u2ipvub6kbm3dqzliao.png" alt="Learn JavaScript logical operators" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;📘 &lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Logical operators in JavaScript are essential for writing conditions and controlling program logic. They’re used in almost every JavaScript project—from form validation to access control.&lt;/p&gt;

&lt;p&gt;In this complete guide, you’ll learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How &amp;amp;&amp;amp;, ||, and ! work in JavaScript&lt;/li&gt;
&lt;li&gt;Truthy and falsy values&lt;/li&gt;
&lt;li&gt;Real-world and interview-level examples&lt;/li&gt;
&lt;li&gt;Common mistakes to avoid&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;🔹 &lt;strong&gt;What Are Logical Operators?&lt;/strong&gt;&lt;br&gt;
JavaScript has three main logical operators:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;| Operator | Name        | Description                              |            |                                     |
| -------- | ----------- | ---------------------------------------- | ---------- | ----------------------------------- |
| `&amp;amp;&amp;amp;`     | Logical AND | Returns true if **both** values are true |            |                                     |
| \`       |             | \`                                       | Logical OR | Returns true if **any one** is true |
| `!`      | Logical NOT | Reverses the truth value (negates it)    |            |                                     |

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

&lt;/div&gt;






&lt;p&gt;✅ &lt;strong&gt;1. Logical AND (&amp;amp;&amp;amp;)&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 age = 25;
const isCitizen = true;

if (age &amp;gt; 18 &amp;amp;&amp;amp; isCitizen) {
  console.log("You can vote!");
}

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

&lt;/div&gt;



&lt;p&gt;💡 If the first condition is &lt;code&gt;false&lt;/code&gt;, JavaScript skips the second—this is called short-circuiting&lt;/p&gt;




&lt;p&gt;✅ &lt;strong&gt;2. Logical OR (||)&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 hasLicense = false;
const hasPermit = true;

if (hasLicense || hasPermit) {
  console.log("You can drive!");
}

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

&lt;/div&gt;



&lt;p&gt;💡 If the first condition is &lt;code&gt;true&lt;/code&gt;, the second is ignored.&lt;/p&gt;




&lt;p&gt;✅ &lt;strong&gt;3. Logical NOT (!)&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 isLoggedIn = false;

if (!isLoggedIn) {
  console.log("Please log in!");
}

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

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;!&lt;/code&gt; operator flips the value. &lt;code&gt;!true&lt;/code&gt; becomes &lt;code&gt;false&lt;/code&gt;, and &lt;code&gt;!false&lt;/code&gt; becomes &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;




&lt;p&gt;🔍 &lt;strong&gt;Truthy vs Falsy Values in JavaScript&lt;/strong&gt;&lt;br&gt;
In JavaScript, non-boolean values can be treated as true or false.&lt;br&gt;
&lt;strong&gt;Falsy values:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;false&lt;/li&gt;
&lt;li&gt;0&lt;/li&gt;
&lt;li&gt;""&lt;/li&gt;
&lt;li&gt;null&lt;/li&gt;
&lt;li&gt;undefined&lt;/li&gt;
&lt;li&gt;NaN&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Truthy values:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Any non-zero number&lt;/li&gt;
&lt;li&gt;Non-empty string&lt;/li&gt;
&lt;li&gt;Objects/Arrays
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const username = "";

if (!username) {
  console.log("Username is required!");
}

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

&lt;/div&gt;




&lt;p&gt;🔄 &lt;strong&gt;Real-World Examples&lt;/strong&gt;&lt;br&gt;
✅ &lt;strong&gt;1. Using || for Defaults&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 = "" || "Guest";
console.log(name); // Guest

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

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;2. Conditional Rendering with &amp;amp;&amp;amp;&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 = { isAdmin: true };

user &amp;amp;&amp;amp; user.isAdmin &amp;amp;&amp;amp; console.log("Welcome Admin!");

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

&lt;/div&gt;






&lt;p&gt;⚠️ &lt;strong&gt;Gotchas to Know&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 || "fallback"); // "fallback"
console.log(0 &amp;amp;&amp;amp; "fallback"); // 0

console.log(!!"hello"); // true
console.log(!!0); // false

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

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;!!&lt;/code&gt; to explicitly convert to boolean.&lt;/p&gt;




&lt;p&gt;✅ &lt;strong&gt;Ternary with Logical Check&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 isLoggedIn = true;
const message = isLoggedIn ? "Welcome back!" : "Please log in.";
console.log(message);

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

&lt;/div&gt;






&lt;p&gt;🧩 &lt;strong&gt;Practice Challenge&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;function canAccess(age, isLoggedIn) {
  return age &amp;gt;= 18 &amp;amp;&amp;amp; isLoggedIn;
}

console.log(canAccess(20, true)); // true
console.log(canAccess(15, true)); // false

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

&lt;/div&gt;






&lt;p&gt;❓ &lt;strong&gt;FAQs&lt;/strong&gt;&lt;br&gt;
Q: Can logical operators work on non-booleans?&lt;br&gt;
Yes! JavaScript uses type coercion to convert them into truthy or falsy.&lt;/p&gt;

&lt;p&gt;Q: Why use || for default values?&lt;br&gt;
Because if the first value is falsy, it returns the fallback.&lt;/p&gt;




&lt;p&gt;📖 Original Blog:&lt;br&gt;
👉 Read more &lt;a href="https://webcodingwithankur.blogspot.com/2025/07/logical-operators-in-javascript-guide.html" rel="noopener noreferrer"&gt;Logical Operators in JavaScript&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Use indexOf() in JavaScript – Complete Guide with Examples</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Tue, 08 Jul 2025 07:31:32 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/how-to-use-indexof-in-javascript-complete-guide-with-examples-2277</link>
      <guid>https://dev.to/webtechnology_tutorials_f/how-to-use-indexof-in-javascript-complete-guide-with-examples-2277</guid>
      <description>&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%2Fqvosy8vsrb2s7zgx5yt8.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%2Fqvosy8vsrb2s7zgx5yt8.png" alt="Learn how to use indexOf() in JavaScript with syntax" width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A beginner-friendly deep dive into JavaScript’s powerful indexOf() method — from strings to arrays, and real-world examples.&lt;/p&gt;




&lt;p&gt;🔍 &lt;strong&gt;What is indexOf() in JavaScript?&lt;/strong&gt;&lt;br&gt;
The indexOf() method is used to find the position (index) of a specific element inside a string or array. If it’s not found, it returns -1.&lt;/p&gt;



&lt;p&gt;🧪 &lt;strong&gt;Syntax&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;For Strings&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.indexOf(searchValue, startIndex)

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For Arrays:&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;array.indexOf(searchElement, fromIndex)

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

&lt;/div&gt;






&lt;p&gt;📘 &lt;strong&gt;Using indexOf() with Strings&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 text = "JavaScript is amazing";
console.log(text.indexOf("Script")); // 4

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

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Case Sensitivity&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(text.indexOf("script")); // -1

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

&lt;/div&gt;






&lt;p&gt;🔁 &lt;strong&gt;First Occurrence&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 sentence = "I love JavaScript because JavaScript is fun!";
console.log(sentence.indexOf("JavaScript")); // 7

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

&lt;/div&gt;






&lt;p&gt;🕵️‍♂️ &lt;strong&gt;Find All Occurrences&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 str = "JS is cool. JS is powerful. JS is everywhere!";
let index = str.indexOf("JS");
while (index !== -1) {
  console.log("Found at:", index);
  index = str.indexOf("JS", index + 1);
}

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

&lt;/div&gt;






&lt;p&gt;🧾 &lt;strong&gt;Using indexOf() with Arrays&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 fruits = ["apple", "banana", "cherry", "apple"];
console.log(fruits.indexOf("apple")); // 0
console.log(fruits.indexOf("cherry")); // 2

&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;const numbers = [1, 5, 10, 15];
console.log(numbers.indexOf(10)); // 2
console.log(numbers.indexOf(20)); // -1

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

&lt;/div&gt;






&lt;p&gt;🎯 &lt;strong&gt;Check if an Element Exists&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;if (fruits.indexOf("banana") !== -1) {
  console.log("Banana is in the list!");
}

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

&lt;/div&gt;






&lt;p&gt;🧠 &lt;code&gt;indexOf()&lt;/code&gt; vs &lt;code&gt;includes()&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;| Feature  | indexOf()     | includes()      |
| -------- | ------------- | --------------- |
| Returns  | Index or -1   | true / false    |
| Use Case | Find position | Check existence |

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

&lt;/div&gt;






&lt;p&gt;⚡ &lt;strong&gt;Performance Tip&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;// Simpler check
arr.includes("item");

// More flexible
arr.indexOf("item") !== -1

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

&lt;/div&gt;






&lt;p&gt;📌 &lt;strong&gt;Real-World Use Case&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 input = "Learn JavaScript the fun way!";
const term = "JavaScript";

if (input.indexOf(term) !== -1) {
  console.log(`The term "${term}" exists in the sentence.`);
}

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

&lt;/div&gt;






&lt;p&gt;❓ &lt;strong&gt;Common Interview Question&lt;/strong&gt;&lt;br&gt;
Q: How can you check if a string contains a word without using regex?&lt;br&gt;
A: Use &lt;code&gt;.indexOf()&lt;/code&gt; and compare the result with &lt;code&gt;-1&lt;/code&gt;.&lt;/p&gt;



&lt;p&gt;🧩 &lt;strong&gt;Practice Challenge&lt;/strong&gt;&lt;br&gt;
Write a function that finds if the word &lt;code&gt;"React"&lt;/code&gt; exists in a sentence and returns its position.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function findReact(sentence) {
  return sentence.indexOf("React");
}

console.log(findReact("I love React and JavaScript")); // 7

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

&lt;/div&gt;






&lt;p&gt;✅ &lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Works on strings and arrays&lt;/li&gt;
&lt;li&gt;Returns index if found, -1 if not&lt;/li&gt;
&lt;li&gt;Case-sensitive&lt;/li&gt;
&lt;li&gt;Use includes() for existence check only&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;🧠 &lt;strong&gt;FAQs&lt;/strong&gt;&lt;br&gt;
Q: &lt;strong&gt;Can indexOf() find objects in an array?&lt;/strong&gt;&lt;br&gt;
A: No, only primitive values like strings, numbers.&lt;/p&gt;

&lt;p&gt;Q: &lt;strong&gt;What if multiple matches exist?&lt;/strong&gt;&lt;br&gt;
A: It returns the first index only.&lt;/p&gt;

&lt;p&gt;Q: &lt;strong&gt;Does indexOf() modify the array or string?&lt;/strong&gt;&lt;br&gt;
A: No, it is non-mutating.&lt;/p&gt;




&lt;p&gt;🔥 &lt;strong&gt;Want More?&lt;/strong&gt;&lt;br&gt;
Read the full blog with images and formatting here:&lt;br&gt;
👉 &lt;a href="https://webcodingwithankur.blogspot.com/2025/07/indexof-in-javascript-complete-guide.html" rel="noopener noreferrer"&gt;https://webcodingwithankur.blogspot.com/2025/07/indexof-in-javascript-complete-guide.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>What’s New in React Router 7? Features &amp; Setup Guide</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Sun, 06 Jul 2025 06:28:18 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/whats-new-in-react-router-7-features-setup-guide-34je</link>
      <guid>https://dev.to/webtechnology_tutorials_f/whats-new-in-react-router-7-features-setup-guide-34je</guid>
      <description>&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%2F23lkbw3znfw24ahg0fib.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%2F23lkbw3znfw24ahg0fib.png" alt="What new in React Router 7" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React Router 7 is officially out and packed with powerful new features that make routing in React apps more efficient, scalable, and intuitive.&lt;/p&gt;

&lt;p&gt;Whether you’re upgrading from v6 or starting a new project, this guide covers everything you need:&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;New features in React Router 7&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;⚙️ How to install and set it up&lt;/li&gt;
&lt;li&gt;💻 Code examples using createBrowserRouter, loaders, layouts&lt;/li&gt;
&lt;li&gt;📦 Real-world use cases for Suspense and nested routing&lt;/li&gt;
&lt;li&gt;🤔 Developer Q&amp;amp;A and migration tips&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;✨ &lt;strong&gt;Why React Router 7 is a Big Deal&lt;/strong&gt;&lt;br&gt;
React Router 7 supports the latest advancements in React — including Suspense, lazy loading, data loaders, and layout-based routing. It's designed to work seamlessly with React 18+ and future React 19 features.&lt;/p&gt;



&lt;p&gt;🔍 &lt;strong&gt;Key Features in React Router 7&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Built-in Suspense support for route-level code-splitting&lt;/li&gt;
&lt;li&gt;✅ Better nested routing via layouts&lt;/li&gt;
&lt;li&gt;✅ Loader and action support to fetch data before rendering&lt;/li&gt;
&lt;li&gt;✅ New hooks like &lt;code&gt;useNavigation()&lt;/code&gt; and &lt;code&gt;useRouteLoaderData()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;✅ Optimized support for modern rendering patterns&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;⚙️ &lt;strong&gt;Installation &amp;amp; Setup&lt;/strong&gt;&lt;br&gt;
Run the following to install:&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@7

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

&lt;/div&gt;



&lt;p&gt;For a new app with Vite:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vite@latest my-app --template react
cd my-app
npm install
npm install react-router-dom@7

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

&lt;/div&gt;






&lt;p&gt;📦 &lt;strong&gt;Basic Router 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 { createBrowserRouter, RouterProvider } from "react-router-dom";
import Home from "./pages/Home";
import About from "./pages/About";

const router = createBrowserRouter([
  { path: "/", element: &amp;lt;Home /&amp;gt; },
  { path: "/about", element: &amp;lt;About /&amp;gt; },
]);

function App() {
  return &amp;lt;RouterProvider router={router} /&amp;gt;;
}

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

&lt;/div&gt;






&lt;p&gt;🧱 &lt;strong&gt;Nested Routes with Layout&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 RootLayout from "./layouts/RootLayout";
import Dashboard from "./pages/Dashboard";
import Profile from "./pages/Profile";

const router = createBrowserRouter([
  {
    path: "/",
    element: &amp;lt;RootLayout /&amp;gt;,
    children: [
      { path: "dashboard", element: &amp;lt;Dashboard /&amp;gt; },
      { path: "profile", element: &amp;lt;Profile /&amp;gt; },
    ],
  },
]);

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

&lt;/div&gt;



&lt;p&gt;React Router 7 makes layout nesting easier using its built-in child routes structure.&lt;/p&gt;




&lt;p&gt;⚡ &lt;strong&gt;Preload Data with Loaders&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;// routes.js
{
  path: "user/:id",
  loader: async ({ params }) =&amp;gt; {
    return fetchUser(params.id);
  },
  element: &amp;lt;UserProfile /&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;// Inside UserProfile.jsx
import { useLoaderData } from "react-router-dom";

const UserProfile = () =&amp;gt; {
  const user = useLoaderData();
  return &amp;lt;div&amp;gt;Welcome {user.name}&amp;lt;/div&amp;gt;;
}

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

&lt;/div&gt;






&lt;p&gt;❓ &lt;strong&gt;FAQ: Common Questions About React Router 7&lt;/strong&gt;&lt;br&gt;
Q. &lt;strong&gt;Is this compatible with React 18 or 19?&lt;/strong&gt;&lt;br&gt;
✔️ Yes, fully compatible.&lt;/p&gt;

&lt;p&gt;Q. &lt;strong&gt;Do I need to rewrite my app?&lt;/strong&gt;&lt;br&gt;
🔁 Not completely. But you may need to migrate &lt;code&gt;Routes&lt;/code&gt; → &lt;code&gt;RouterProvider&lt;/code&gt;, and update hooks.&lt;/p&gt;

&lt;p&gt;Q. &lt;strong&gt;Can I use it with Suspense and lazy?&lt;/strong&gt;&lt;br&gt;
✅ Yes! It's designed for it.&lt;/p&gt;

&lt;p&gt;Q. &lt;strong&gt;Is &lt;code&gt;react-router-dom&lt;/code&gt; still used?&lt;/strong&gt;&lt;br&gt;
🎯 Yes, just install version &lt;code&gt;@7&lt;/code&gt;.&lt;/p&gt;




&lt;p&gt;📖 Read Full Guide on Blogger&lt;br&gt;
👉 &lt;a href="https://webcodingwithankur.blogspot.com/2025/07/whats-new-in-react-router-7-features.html" rel="noopener noreferrer"&gt;https://webcodingwithankur.blogspot.com/2025/07/whats-new-in-react-router-7-features.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactrouter</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How to Create a React App with Vite and Tailwind (Beginner Guide)</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Sat, 05 Jul 2025 05:36:09 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/how-to-create-a-react-app-with-vite-and-tailwind-beginner-guide-1l39</link>
      <guid>https://dev.to/webtechnology_tutorials_f/how-to-create-a-react-app-with-vite-and-tailwind-beginner-guide-1l39</guid>
      <description>&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%2Fc5bpsytjpt22h4ljihup.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%2Fc5bpsytjpt22h4ljihup.png" alt="How to Create a React App with Vite and Tailwind" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Creating fast, customizable, and modern web apps has never been easier with &lt;strong&gt;React&lt;/strong&gt;, &lt;strong&gt;Vite&lt;/strong&gt;, and &lt;strong&gt;Tailwind CSS&lt;/strong&gt;. This beginner-friendly guide will help you build a fully functional React project with Tailwind styling using Vite as your development tool.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Why Use React + Vite + Tailwind?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;⚡ &lt;strong&gt;Vite&lt;/strong&gt;: Superfast dev server and build tool.&lt;/li&gt;
&lt;li&gt;⚛ &lt;strong&gt;React&lt;/strong&gt;: Flexible and scalable UI library.&lt;/li&gt;
&lt;li&gt;💨 &lt;strong&gt;Tailwind CSS&lt;/strong&gt;: Utility-first CSS for rapid UI development.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧰 Prerequisites
&lt;/h2&gt;

&lt;p&gt;Make sure you have the following installed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js (v18+)&lt;/li&gt;
&lt;li&gt;npm or yarn&lt;/li&gt;
&lt;li&gt;VS Code or any code editor&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📦 Step 1: Create a React App Using Vite
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vite@latest my-react-app --template react
cd my-react-app
npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;💨 &lt;strong&gt;Step 2: Install Tailwind CSS&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 -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

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

&lt;/div&gt;






&lt;p&gt;✍️ &lt;strong&gt;Step 3: Configure Tailwind&lt;/strong&gt;&lt;br&gt;
Update tailwind.config.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default {
  content: [
    "./index.html",
    "./src/**/*.{js,ts,jsx,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

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

&lt;/div&gt;



&lt;p&gt;Add this to &lt;code&gt;src/index.css&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;@tailwind base;
@tailwind components;
@tailwind utilities;

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

&lt;/div&gt;






&lt;p&gt;🔄 &lt;strong&gt;Step 4: Start the Dev Server&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 run dev

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

&lt;/div&gt;



&lt;p&gt;Visit &lt;code&gt;http://localhost:5173&lt;/code&gt; in your browser.&lt;/p&gt;




&lt;p&gt;🧪 &lt;strong&gt;Step 5: Test Tailwind Styling&lt;/strong&gt;&lt;br&gt;
Replace the content of &lt;code&gt;App.jsx&lt;/code&gt; with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function App() {
  return (
    &amp;lt;div className="flex items-center justify-center h-screen bg-gradient-to-r from-purple-500 to-blue-500 text-white text-4xl font-bold"&amp;gt;
      Hello Tailwind + React + Vite! 🚀
    &amp;lt;/div&amp;gt;
  );
}

export default App;

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

&lt;/div&gt;






&lt;p&gt;✅ &lt;strong&gt;Folder Structure&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;my-react-app/
├── index.html
├── tailwind.config.js
├── postcss.config.js
└── src/
    ├── App.jsx
    ├── main.jsx
    └── index.css

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

&lt;/div&gt;






&lt;p&gt;❓ &lt;strong&gt;FAQs&lt;/strong&gt;&lt;br&gt;
Q: &lt;strong&gt;Can I use TypeScript with this setup?&lt;/strong&gt;&lt;br&gt;
A: Yes! Choose &lt;code&gt;react-ts&lt;/code&gt; template while initializing with Vite.&lt;/p&gt;

&lt;p&gt;Q: &lt;strong&gt;Is this production-ready?&lt;/strong&gt;&lt;br&gt;
A: Yes. Vite offers optimized builds and Tailwind supports purging unused CSS.&lt;/p&gt;

&lt;p&gt;Q: &lt;strong&gt;Can I use UI libraries with Tailwind?&lt;/strong&gt;&lt;br&gt;
A: Absolutely. Try Headless UI, Radix UI, or ShadCN for React-compatible components.&lt;/p&gt;




&lt;p&gt;🧠 &lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
Combining React, Vite, and Tailwind gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🚀 Speedy dev experience and build times&lt;/li&gt;
&lt;li&gt;✨ Clean, scalable, component-based architecture&lt;/li&gt;
&lt;li&gt;🎨 Beautiful, responsive UIs using utility-first CSS&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;📎 &lt;strong&gt;Original Blog Post Link&lt;/strong&gt;&lt;br&gt;
👉 Read it on &lt;a href="https://webcodingwithankur.blogspot.com/2025/07/how-to-create-react-app-with-vite-tailwind.html" rel="noopener noreferrer"&gt;How to Create a React App with Vite and Tailwind (Beginner Guide)&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>vite</category>
      <category>tailwindcss</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Fixing `npx tailwindcss init` Error – Could Not Determine Executable</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Thu, 03 Jul 2025 06:42:28 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/fixing-npx-tailwindcss-init-error-could-not-determine-executable-31hp</link>
      <guid>https://dev.to/webtechnology_tutorials_f/fixing-npx-tailwindcss-init-error-could-not-determine-executable-31hp</guid>
      <description>&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%2Fjgum8pfdaxu1awoy2tnb.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%2Fjgum8pfdaxu1awoy2tnb.png" alt="Step-by-step setup guide with npm and CLI support." width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📖 &lt;strong&gt;Intro:&lt;/strong&gt;&lt;br&gt;
If you've run into the frustrating error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx tailwindcss init
npm ERR! could not determine executable to run

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

&lt;/div&gt;



&lt;p&gt;You're not alone. This error often appears when setting up Tailwind CSS in a new project. In this post, I’ll explain why it happens and how to fix it quickly using the right commands and setup.&lt;/p&gt;

&lt;p&gt;Whether you're working with React, Node.js, or just setting up Tailwind for the first time, this guide is for you.&lt;/p&gt;




&lt;p&gt;🚨 &lt;strong&gt;Why Does This Error Happen?&lt;/strong&gt;&lt;br&gt;
This typically happens when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The tailwindcss CLI is not installed&lt;/li&gt;
&lt;li&gt;There is no package.json in your project&lt;/li&gt;
&lt;li&gt;npx can’t locate the executable&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;✅ &lt;strong&gt;Fixes (With Steps)&lt;/strong&gt;&lt;br&gt;
✅ &lt;strong&gt;Fix 1: Install Tailwind CSS First&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 -D tailwindcss
npx tailwindcss init

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

&lt;/div&gt;






&lt;p&gt;✅ &lt;strong&gt;Fix 2: Initialize package.json if Missing&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 init -y
npm install -D tailwindcss
npx tailwindcss init

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

&lt;/div&gt;






&lt;p&gt;✅ &lt;strong&gt;Fix 3: Clear NPX Cache (Optional)&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;npx clear-npx-cache
npx tailwindcss init

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

&lt;/div&gt;






&lt;p&gt;✅ &lt;strong&gt;Fix 4: Run Directly from Node Modules&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;node_modules/.bin/tailwindcss init

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

&lt;/div&gt;






&lt;p&gt;💡 &lt;strong&gt;Bonus: Use CDN for Quick Testing (No Init Required)&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;script src="https://cdn.tailwindcss.com"&amp;gt;&amp;lt;/script&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Not recommended for production.&lt;/code&gt;&lt;/p&gt;




&lt;p&gt;❌ &lt;strong&gt;Common Mistakes&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;| Mistake                         | Fix                         |
| ------------------------------- | --------------------------- |
| Running `npx` before installing | Install `tailwindcss` first |
| No package.json                 | Run `npm init -y`           |
| Using outdated Node/npm         | Update Node.js to v14+      |

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

&lt;/div&gt;






&lt;p&gt;🔎 &lt;strong&gt;Also Read:&lt;/strong&gt;&lt;br&gt;
If you're exploring performance in React:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://webcodingwithankur.blogspot.com/2025/06/usememo-in-react-performance-optimization.html" rel="noopener noreferrer"&gt;How to useMemo in React to Improve Performance&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;📘 &lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
This error is just a small roadblock when working with Tailwind CSS. With the right install sequence and project setup, you’ll be up and running in no time.&lt;/p&gt;

&lt;p&gt;Want a full visual guide and code examples?&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://webcodingwithankur.blogspot.com/2025/07/fix-npx-tailwindcss-init-npm-error.html" rel="noopener noreferrer"&gt;Read the full blog post here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>javascript</category>
      <category>frontend</category>
      <category>npm</category>
    </item>
    <item>
      <title>Understanding `filter()` as a Higher-Order Function in JavaScript</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Wed, 02 Jul 2025 08:29:36 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/understanding-filter-as-a-higher-order-function-in-javascript-3oa0</link>
      <guid>https://dev.to/webtechnology_tutorials_f/understanding-filter-as-a-higher-order-function-in-javascript-3oa0</guid>
      <description>&lt;p&gt;JavaScript treats functions as first-class citizens, allowing us to pass them around, return them, and even compose them. This flexibility gives birth to &lt;strong&gt;higher-order functions&lt;/strong&gt;, a concept that powers much of modern JavaScript — especially array methods like &lt;code&gt;filter()&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 What is a Higher-Order Function?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;higher-order function&lt;/strong&gt; is one that either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Accepts another function as an argument, or
&lt;/li&gt;
&lt;li&gt;Returns a function as its output.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;greetUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;greetingFn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;greetingFn&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sayHello&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, Developer!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;greetUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sayHello&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Output: Hello, Developer!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;greetUser&lt;/code&gt; is a higher-order function because it takes a function as a parameter.&lt;/p&gt;




&lt;p&gt;☕ &lt;strong&gt;Real-World Analogy: Filter Coffee&lt;/strong&gt;&lt;br&gt;
Imagine you’re brewing coffee through a filter. Only the finest particles pass through, giving you the perfect brew. Similarly, JavaScript’s &lt;code&gt;filter()&lt;/code&gt; method passes only the elements that meet a condition — defined via a callback function.&lt;/p&gt;



&lt;p&gt;💡 &lt;strong&gt;What is &lt;code&gt;filter()&lt;/code&gt; in JavaScript?&lt;/strong&gt;&lt;br&gt;
The filter() method creates a new array with elements that pass a specific test (provided by a callback).&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;array.filter(callbackFunction(element, index, array), thisArg)

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

&lt;/div&gt;






&lt;p&gt;🔧 &lt;strong&gt;Why is &lt;code&gt;filter()&lt;/code&gt; a Higher-Order Function?&lt;/strong&gt;&lt;br&gt;
Because &lt;code&gt;filter()&lt;/code&gt; &lt;strong&gt;accepts a callback function&lt;/strong&gt;, it is by definition a higher-order function.&lt;/p&gt;

&lt;p&gt;You define the logic; &lt;code&gt;filter()&lt;/code&gt; applies it dynamically to each array element — making it modular, reusable, and clean.&lt;/p&gt;



&lt;p&gt;✅ &lt;strong&gt;Practical Examples&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;1. Filter Even Numbers&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 numbers = [1, 2, 3, 4, 5];
const even = numbers.filter(num =&amp;gt; num % 2 === 0);
console.log(even); // [2, 4]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Filter Adults from User List&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 users = [
  { name: "Ankur", age: 28 },
  { name: "Rahul", age: 17 },
  { name: "Priya", age: 21 }
];

const adults = users.filter(user =&amp;gt; user.age &amp;gt;= 18);
console.log(adults);

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Modular Filtering with Named Functions&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;function isAdult(user) {
  return user.age &amp;gt;= 18;
}

const adultUsers = users.filter(isAdult);

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

&lt;/div&gt;






&lt;p&gt;🔄 &lt;strong&gt;Chaining with Other Array Methods&lt;/strong&gt;&lt;br&gt;
You can chain &lt;code&gt;filter()&lt;/code&gt; with &lt;code&gt;map()&lt;/code&gt; and &lt;code&gt;reduce()&lt;/code&gt; for powerful data transformations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const prices = [100, 200, 300, 400];

const discounted = prices
  .filter(price =&amp;gt; price &amp;gt; 200)
  .map(price =&amp;gt; price * 0.9);

console.log(discounted); // [270, 360]

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

&lt;/div&gt;






&lt;p&gt;❓ &lt;strong&gt;Common Questions&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Q: Does &lt;code&gt;filter()&lt;/code&gt; mutate the original array?&lt;/strong&gt;&lt;br&gt;
A: No. &lt;code&gt;filter()&lt;/code&gt; returns a new array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q: Can I filter based on multiple conditions?&lt;/strong&gt;&lt;br&gt;
A: Yes, just use logical operators in the callback:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const filtered = numbers.filter(num =&amp;gt; num &amp;gt; 10 &amp;amp;&amp;amp; num &amp;lt; 50);

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Q: Can I use &lt;code&gt;filter()&lt;/code&gt; with objects?&lt;/strong&gt;&lt;br&gt;
A: Use &lt;code&gt;Object.entries()&lt;/code&gt; + &lt;code&gt;filter()&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;const obj = { a: 1, b: 2, c: 3 };
const filtered = Object.entries(obj)
  .filter(([key, value]) =&amp;gt; value &amp;gt; 1);

console.log(Object.fromEntries(filtered)); // { b: 2, c: 3 }

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

&lt;/div&gt;






&lt;p&gt;✅ &lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
Understanding &lt;code&gt;filter()&lt;/code&gt; as a higher-order function is essential for writing clean, functional, and maintainable JavaScript. It’s not just about filtering — it’s about mastering function composition and code reusability.&lt;/p&gt;




&lt;p&gt;🔗 Original Blog Link&lt;br&gt;
📖 &lt;a href="https://webcodingwithankur.blogspot.com/2025/07/javascript-filter-higher-order-function.html" rel="noopener noreferrer"&gt;https://webcodingwithankur.blogspot.com/2025/07/javascript-filter-higher-order-function.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>functional</category>
    </item>
    <item>
      <title>🧠 Mastering useCallback in React: Prevent Unnecessary Re-Renders and Boost Performance</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Mon, 30 Jun 2025 08:06:53 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/mastering-usecallback-in-react-prevent-unnecessary-re-renders-and-boost-performance-5hmb</link>
      <guid>https://dev.to/webtechnology_tutorials_f/mastering-usecallback-in-react-prevent-unnecessary-re-renders-and-boost-performance-5hmb</guid>
      <description>&lt;p&gt;&lt;em&gt;Ever wondered why your child components keep re-rendering even when their props haven't changed? Or why performance drops in large React apps? The answer might lie in one powerful but underused hook — useCallback.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this blog post, we’ll explore React’s useCallback hook in depth. You’ll learn how it works, when to use it, and how to pair it with tools like React.memo, useState, and useMemo for real-world performance optimization.&lt;/p&gt;




&lt;p&gt;🔍 &lt;strong&gt;What is useCallback in React?&lt;/strong&gt;&lt;br&gt;
useCallback is a React Hook that returns a &lt;strong&gt;memoized version of a callback&lt;/strong&gt; function. It prevents the function from being re-created on every render — unless the dependencies change.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const memoizedFn = useCallback(() =&amp;gt; {
  doSomething(a, b);
}, [a, b]);

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

&lt;/div&gt;



&lt;p&gt;This becomes crucial when you're passing callbacks to memoized child components (&lt;code&gt;React.memo&lt;/code&gt;), which rely on reference equality to avoid re-rendering.&lt;/p&gt;




&lt;p&gt;🧠 &lt;strong&gt;Real-World Analogy&lt;/strong&gt;&lt;br&gt;
Think of your callback as a phone number. If it changes every time, the person you're calling (your child component) thinks it's someone new — and answers again. useCallback keeps the number the same unless there's a real reason to change.&lt;/p&gt;



&lt;p&gt;✅ &lt;strong&gt;Why Use useCallback?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prevent unnecessary re-renders&lt;/li&gt;
&lt;li&gt;Improve app performance&lt;/li&gt;
&lt;li&gt;Stabilize function references passed as props&lt;/li&gt;
&lt;li&gt;Avoid expensive recalculations&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;❌ &lt;strong&gt;Without&lt;/strong&gt; &lt;code&gt;useCallback&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;const Parent = () =&amp;gt; {
  const [count, setCount] = useState(0);

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

  return (
    &amp;lt;&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCount(count + 1)}&amp;gt;Increment&amp;lt;/button&amp;gt;
      &amp;lt;Child onClick={handleClick} /&amp;gt;
    &amp;lt;/&amp;gt;
  );
};

const Child = React.memo(({ onClick }) =&amp;gt; {
  console.log("Child re-rendered");
  return &amp;lt;button onClick={onClick}&amp;gt;Click me&amp;lt;/button&amp;gt;;
});

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

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;Child&lt;/code&gt; re-renders even when it doesn’t need to — because &lt;code&gt;handleClick&lt;/code&gt; is recreated on every render.&lt;/p&gt;




&lt;p&gt;✅ &lt;strong&gt;With&lt;/strong&gt; &lt;code&gt;useCallback&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;const handleClick = useCallback(() =&amp;gt; {
  console.log("Clicked");
}, []);

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

&lt;/div&gt;



&lt;p&gt;Now the &lt;code&gt;Child&lt;/code&gt; component won’t re-render unnecessarily, thanks to the stable function reference.&lt;/p&gt;




&lt;p&gt;🧪 &lt;code&gt;useCallback&lt;/code&gt; vs &lt;code&gt;useMemo&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;| Hook          | Purpose                 | Returns                 |
| ------------- | ----------------------- | ----------------------- |
| `useCallback` | Memoizes a **function** | Same function reference |
| `useMemo`     | Memoizes a **value**    | Result of computation   |

&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;const memoizedCallback = useCallback(() =&amp;gt; compute(a, b), [a, b]);
const memoizedValue = useMemo(() =&amp;gt; compute(a, b), [a, b]);

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

&lt;/div&gt;






&lt;p&gt;🔍 &lt;strong&gt;Debug With React DevTools&lt;/strong&gt;&lt;br&gt;
Use the &lt;strong&gt;Profiler&lt;/strong&gt; in React DevTools to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inspect render frequency&lt;/li&gt;
&lt;li&gt;Validate optimizations&lt;/li&gt;
&lt;li&gt;Track function reference changes&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;⚙️ &lt;strong&gt;Best Practices&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅ Use with &lt;code&gt;React.memo&lt;/code&gt; for child components&lt;br&gt;
✅ Use when function dependencies change infrequently&lt;br&gt;
✅ Avoid overuse — it has memory overhead&lt;br&gt;
✅ Always pass accurate dependencies&lt;br&gt;
✅ Combine with &lt;code&gt;useMemo&lt;/code&gt; when needed&lt;/p&gt;



&lt;p&gt;💡 &lt;strong&gt;Bonus: Working with&lt;/strong&gt; &lt;code&gt;useState&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;const [count, setCount] = useState(0);
const increment = useCallback(() =&amp;gt; {
  setCount(prev =&amp;gt; prev + 1);
}, []);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;💬 Let's Connect&lt;br&gt;
Have questions or want to share how you use useCallback? Drop a comment below or explore more tips on my blog:&lt;br&gt;
🔗  &lt;a href="https://webcodingwithankur.blogspot.com/2025/06/mastering-usecallback-in-react-performance-optimization.html" rel="noopener noreferrer"&gt;Mastering useCallback in React&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>🔍 Deep Dive into useMemo in React.js: Optimize Performance Like a Pro</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Sun, 29 Jun 2025 07:45:12 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/deep-dive-into-usememo-in-reactjs-optimize-performance-like-a-pro-1i01</link>
      <guid>https://dev.to/webtechnology_tutorials_f/deep-dive-into-usememo-in-reactjs-optimize-performance-like-a-pro-1i01</guid>
      <description>&lt;p&gt;React is blazing fast, but as your app scales, performance issues like unnecessary re-renders and repeated calculations can sneak in. That’s where the useMemo Hook becomes your secret weapon.&lt;/p&gt;




&lt;p&gt;✅ &lt;strong&gt;In this post, you'll learn:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is useMemo in React?&lt;/li&gt;
&lt;li&gt;Why and when to use it&lt;/li&gt;
&lt;li&gt;Real-world analogies&lt;/li&gt;
&lt;li&gt;Optimization use cases with child components&lt;/li&gt;
&lt;li&gt;Code examples and diagrams&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;🧠 &lt;strong&gt;What is useMemo?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;useMemo&lt;/code&gt; is a React Hook that memoizes the result of a function, meaning it will only re-run the computation when its dependencies change.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 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 memoizedValue = useMemo(() =&amp;gt; computeExpensiveValue(a, b), [a, b]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It helps avoid recomputing things unnecessarily and boosts performance, especially in large React apps.&lt;/p&gt;




&lt;p&gt;🎯 &lt;strong&gt;Why use useMemo?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;React re-renders on every state or prop change. That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expensive calculations may re-run every time&lt;/li&gt;
&lt;li&gt;Child components may re-render even with the same data&lt;/li&gt;
&lt;li&gt;Object and function references get recreated, causing unnecessary changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;useMemo&lt;/code&gt;helps by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Improving performance&lt;/li&gt;
&lt;li&gt;Keeping references stable&lt;/li&gt;
&lt;li&gt;Preventing unnecessary child re-renders&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;🚀 &lt;strong&gt;When should you use it?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;useMemo&lt;/code&gt; when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have expensive computations&lt;/li&gt;
&lt;li&gt;You're passing filtered or derived data to child components&lt;/li&gt;
&lt;li&gt;You want to keep prop references stable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But don’t use it everywhere — only where it's needed. Overusing &lt;code&gt;useMemo&lt;/code&gt; can actually reduce performance due to memory and complexity overhead.&lt;/p&gt;




&lt;p&gt;📊 &lt;strong&gt;Real-World Example&lt;/strong&gt;: Factorial Calculator&lt;/p&gt;

&lt;p&gt;Let’s memoize a factorial calculation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const factorial = (n) =&amp;gt; {
  console.log('Calculating...');
  if (n === 0) return 1;
  return n * factorial(n - 1);
};

const result = useMemo(() =&amp;gt; factorial(number), [number]);

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

&lt;/div&gt;



&lt;p&gt;Without &lt;code&gt;useMemo&lt;/code&gt;, the factorial would re-run every time the component re-renders. This optimization avoids that.&lt;/p&gt;




&lt;p&gt;👶 &lt;strong&gt;Child Component Optimization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Example of stabilizing props passed to a memoized child component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const filteredItems = useMemo(() =&amp;gt; {
  return items.filter(item =&amp;gt; item.includes(query));
}, [query]);

&amp;lt;ChildComponent data={filteredItems} /&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;This avoids unnecessary re-renders in &lt;code&gt;ChildComponent&lt;/code&gt;.&lt;/p&gt;




&lt;p&gt;🔄 &lt;strong&gt;useMemo&lt;/strong&gt; vs &lt;strong&gt;useCallback&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;| Hook          | What it Memoizes       | Best For                   |
| ------------- | ---------------------- | -------------------------- |
| `useMemo`     | The return value       | Expensive computed values  |
| `useCallback` | The function reference | Stable event handler props |

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

&lt;/div&gt;






&lt;p&gt;🙋‍♂️ &lt;strong&gt;Frequently Asked Questions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Q: Does &lt;code&gt;useMemo&lt;/code&gt; always improve performance?&lt;br&gt;
A: No. It’s useful only when there are expensive operations or frequent renders.&lt;/p&gt;

&lt;p&gt;Q: Can it be used with async functions?&lt;br&gt;
A: No. &lt;code&gt;useMemo&lt;/code&gt; is synchronous. Use &lt;code&gt;useEffect&lt;/code&gt; or a data-fetching library for async behavior.&lt;/p&gt;

&lt;p&gt;Q: How to track when it works?&lt;br&gt;
A: Use React DevTools to monitor re-renders and props.&lt;/p&gt;




&lt;p&gt;🎬 &lt;strong&gt;Watch Video Tutorial&lt;/strong&gt;&lt;br&gt;
Watch this topic explained on YouTube:&lt;br&gt;
👉 &lt;a href="https://youtu.be/7opz5TfYyws" rel="noopener noreferrer"&gt;https://youtu.be/7opz5TfYyws&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;📌 &lt;strong&gt;Read Full Blog Post with HTML, code formatting, and visuals&lt;/strong&gt;:&lt;br&gt;
👉 &lt;a href="https://webcodingwithankur.blogspot.com/2025/06/usememo-in-react-performance-optimization.html" rel="noopener noreferrer"&gt;https://webcodingwithankur.blogspot.com/2025/06/usememo-in-react-performance-optimization.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>performance</category>
      <category>reacthooks</category>
    </item>
    <item>
      <title>Mastering Promises in JavaScript (With Real-World Examples)</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Sat, 28 Jun 2025 06:32:05 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/mastering-promises-in-javascript-with-real-world-examples-1jo4</link>
      <guid>https://dev.to/webtechnology_tutorials_f/mastering-promises-in-javascript-with-real-world-examples-1jo4</guid>
      <description>&lt;p&gt;Have you ever struggled to understand how JavaScript handles asynchronous code with .then() and .catch()?&lt;/p&gt;

&lt;p&gt;In my latest blog, I break down JavaScript Promises using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🍕 Simple real-life analogies (like ordering pizza)&lt;/li&gt;
&lt;li&gt;💡 Code examples you can copy and run&lt;/li&gt;
&lt;li&gt;🔁 Chaining techniques for cleaner async logic&lt;/li&gt;
&lt;li&gt;❌ Error handling best practices&lt;/li&gt;
&lt;li&gt;✨ Bonus: async/await explained with clarity&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Whether you're a beginner or brushing up your skills, this post will help you move from callback hell to writing modern, clean, and readable asynchronous JavaScript.&lt;/p&gt;

&lt;p&gt;👉 Read the full post here:&lt;br&gt;
🔗 &lt;a href="https://webcodingwithankur.blogspot.com/2025/06/javascript-promises-explained.html.html" rel="noopener noreferrer"&gt;https://webcodingwithankur.blogspot.com/2025/06/javascript-promises-explained.html.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’d love to hear your feedback or questions — drop a comment or let me know what topic you’d like next!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>async</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>What is Hoisting in JavaScript? | Explained with Examples &amp; Visuals</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Fri, 27 Jun 2025 07:01:16 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/what-is-hoisting-in-javascript-explained-with-examples-visuals-4loe</link>
      <guid>https://dev.to/webtechnology_tutorials_f/what-is-hoisting-in-javascript-explained-with-examples-visuals-4loe</guid>
      <description>&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%2Fsoivkcpbu9fpv0p5lm33.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%2Fsoivkcpbu9fpv0p5lm33.png" alt="What is Hoisting in JavaScript" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;🚀 &lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Have you ever encountered an error like undefined is not a function or wondered why a variable seems to exist before it's declared?&lt;br&gt;
Welcome to the quirky world of hoisting in JavaScript — a concept that surprises most developers when they first see it in action.&lt;/p&gt;

&lt;p&gt;In this blog post, you'll learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is hoisting in JavaScript?&lt;/li&gt;
&lt;li&gt;How variables and functions are hoisted&lt;/li&gt;
&lt;li&gt;The difference between var, let, and const&lt;/li&gt;
&lt;li&gt;Real examples and a mental model to remember hoisting&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;🔍 &lt;strong&gt;What is Hoisting?&lt;/strong&gt;&lt;br&gt;
Hoisting is JavaScript’s default behavior of moving declarations to the top of the current scope (function or global).&lt;/p&gt;

&lt;p&gt;This means you can use variables and functions before you declare them — but there’s a catch!&lt;/p&gt;



&lt;p&gt;📌 Example 1: Variable Hoisting with &lt;code&gt;var&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;console.log(name); // undefined
var name = "Ankur";

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

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;br&gt;
The variable &lt;code&gt;name&lt;/code&gt; is hoisted, but only the declaration (not the value) is moved to the top.It’s as if you wrote:&lt;br&gt;
&lt;/p&gt;

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

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

&lt;/div&gt;






&lt;p&gt;🚫 What about &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&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;console.log(age); // ❌ ReferenceError
let age = 25;

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

&lt;/div&gt;



&lt;p&gt;Variables declared with &lt;code&gt;let&lt;/code&gt;and &lt;code&gt;const&lt;/code&gt; are not initialized during hoisting.&lt;br&gt;
They remain in a Temporal Dead Zone (TDZ) until the line of declaration is reached.&lt;/p&gt;



&lt;p&gt;📌 &lt;strong&gt;Example 2: Function Hoisting&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;greet();

function greet() {
  console.log("Hello there!");
}

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

&lt;/div&gt;



&lt;p&gt;✅ This works!&lt;br&gt;
Function declarations are hoisted with their definitions.&lt;/p&gt;



&lt;p&gt;⚠️ &lt;strong&gt;Function Expressions are NOT Hoisted&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;sayHi(); // ❌ TypeError

var sayHi = function () {
  console.log("Hi!");
};

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

&lt;/div&gt;



&lt;p&gt;🧠 &lt;strong&gt;Visual Model of Hoisting&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%2F6s14vtz7xxbd284wkfs8.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%2F6s14vtz7xxbd284wkfs8.png" alt="Visual Model of Hoisting" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;📝 &lt;strong&gt;Summary&lt;/strong&gt;&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;Hoisted?&lt;/th&gt;
&lt;th&gt;Accessible before declaration?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;var&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;⚠️ Yes, but value is undefined&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;let&lt;/code&gt; / &lt;code&gt;const&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;❌ No, in TDZ&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Function Declaration&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Function Expression&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;p&gt;💬 &lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;br&gt;
Understanding hoisting helps prevent bugs and write cleaner JavaScript code.&lt;br&gt;
Next time you write a function or a variable, remember this internal "lift" that JavaScript performs.&lt;/p&gt;




&lt;p&gt;🔗 &lt;strong&gt;Read Full Blog with Code and Visuals&lt;/strong&gt;&lt;br&gt;
👉 &lt;a href="https://webcodingwithankur.blogspot.com/2025/06/what-is-hoisting-in-javascript.html" rel="noopener noreferrer"&gt;https://webcodingwithankur.blogspot.com/2025/06/what-is-hoisting-in-javascript.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>What is Closure in JavaScript? Explained with Real-World Examples</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Thu, 26 Jun 2025 07:25:14 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/what-is-closure-in-javascript-explained-with-real-world-examples-40dj</link>
      <guid>https://dev.to/webtechnology_tutorials_f/what-is-closure-in-javascript-explained-with-real-world-examples-40dj</guid>
      <description>&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%2Fg548ft5pxiy2ago5qadm.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%2Fg548ft5pxiy2ago5qadm.png" alt="What is CLosure in JavaScript" width="800" height="800"&gt;&lt;/a&gt;🔐 &lt;strong&gt;What is Closure in JavaScript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In JavaScript, a &lt;strong&gt;closure&lt;/strong&gt; is created when a function "remembers" variables from its outer lexical scope, even after the outer function has returned.&lt;/p&gt;

&lt;p&gt;Closures enable inner functions to continue accessing variables from the outer function. This powerful concept is key to writing flexible and secure code.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Example of a Closure&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;function outerFunction() {
  let outerVariable = "Hello from the outer scope";

  function innerFunction() {
    console.log(outerVariable);
  }

  return innerFunction;
}

const myClosure = outerFunction();
myClosure(); // Output: Hello from the outer scope

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

&lt;/div&gt;



&lt;p&gt;How it works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;outerFunction&lt;/code&gt;defines a local variable &lt;code&gt;outerVariable&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;innerFunction&lt;/code&gt;is declared inside &lt;code&gt;outerFunction&lt;/code&gt; and uses &lt;code&gt;outerVariable&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;When &lt;code&gt;outerFunction()&lt;/code&gt; is called, it returns &lt;code&gt;innerFunction&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Even though &lt;code&gt;outerFunction()&lt;/code&gt; has completed, the returned &lt;code&gt;innerFunction&lt;/code&gt; still has access to &lt;code&gt;outerVariable&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This behavior is what we call a closure.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Why Use Closures?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Closures are useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You want to keep certain data private.&lt;/li&gt;
&lt;li&gt;You need to preserve a value between function calls.&lt;/li&gt;
&lt;li&gt;You work with asynchronous functions like &lt;code&gt;setTimeout&lt;/code&gt;, &lt;code&gt;setInterval&lt;/code&gt;, or API calls.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Real-World Example: Counter&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;function createCounter() {
  let count = 0;

  return function () {
    count++;
    console.log(count);
  };
}

const counter1 = createCounter();
counter1(); // 1
counter1(); // 2

const counter2 = createCounter();
counter2(); // 1

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

&lt;/div&gt;



&lt;p&gt;Each counter instance has its own independent &lt;code&gt;count&lt;/code&gt; value. This happens because each call to creates a new closure.&lt;/p&gt;




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

&lt;p&gt;A closure is a function bundled with its lexical environment. It gives you the ability to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Maintain state across executions&lt;/li&gt;
&lt;li&gt;Hide and protect variables&lt;/li&gt;
&lt;li&gt;Work more efficiently with asynchronous or functional code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Closures are a core concept in JavaScript and are commonly used in practical applications like module patterns, callbacks, currying, and event handlers.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Read More&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To see the original version of this blog with additional formatting and examples, visit:&lt;br&gt;
&lt;a href="https://webcodingwithankur.blogspot.com/2025/06/what-is-closure-in-javascript.html.html" rel="noopener noreferrer"&gt;https://webcodingwithankur.blogspot.com/2025/06/what-is-closure-in-javascript.html.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>💡 Understanding the JavaScript Event Loop (With Diagrams &amp; Code)</title>
      <dc:creator>WebTechnology Tutorials</dc:creator>
      <pubDate>Wed, 25 Jun 2025 06:10:21 +0000</pubDate>
      <link>https://dev.to/webtechnology_tutorials_f/understanding-the-javascript-event-loop-with-diagrams-code-1en3</link>
      <guid>https://dev.to/webtechnology_tutorials_f/understanding-the-javascript-event-loop-with-diagrams-code-1en3</guid>
      <description>&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%2Fh9820penrrsufnj6v8jc.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%2Fh9820penrrsufnj6v8jc.png" alt="What is JavaScript Event Loop" width="800" height="533"&gt;&lt;/a&gt;&lt;br&gt;
If you're learning JavaScript and asynchronous code makes your brain hurt — you're not alone! 😅&lt;/p&gt;

&lt;p&gt;In my latest blog post, I explain the JavaScript Event Loop in a beginner-friendly way using:&lt;/p&gt;

&lt;p&gt;🧩 Diagrams&lt;br&gt;
🧪 Code examples&lt;br&gt;
📌 Clear explanation of Call Stack, Web APIs, Microtask &amp;amp; Callback Queues&lt;br&gt;
🎓 Real-world reasoning behind Promise vs setTimeout execution order&lt;/p&gt;

&lt;p&gt;Here’s a quick snippet:&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("Start");

setTimeout(() =&amp;gt; {
  console.log("setTimeout");
}, 0);

Promise.resolve().then(() =&amp;gt; {
  console.log("Promise");
});

console.log("End");

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

&lt;/div&gt;






&lt;p&gt;Do you know why Promise logs before setTimeout even when both are async?&lt;br&gt;
💭 The Event Loop knows!&lt;/p&gt;

&lt;p&gt;👉 Read the full article here: &lt;a href="https://webcodingwithankur.blogspot.com/2025/06/what-is-event-loop-in-javascript.html" rel="noopener noreferrer"&gt;https://webcodingwithankur.blogspot.com/2025/06/what-is-event-loop-in-javascript.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔖 If you're preparing for JavaScript interviews or building complex web apps, this guide is a must-read!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>devmeme</category>
      <category>asyncjavascript</category>
      <category>eventloop</category>
    </item>
  </channel>
</rss>
