<?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>Forem: Suvankarr Dash</title>
    <description>The latest articles on Forem by Suvankarr Dash (@dash_suvankarr_).</description>
    <link>https://forem.com/dash_suvankarr_</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%2F3727686%2Fadbf2809-79fb-497b-b28b-2ac528081357.png</url>
      <title>Forem: Suvankarr Dash</title>
      <link>https://forem.com/dash_suvankarr_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dash_suvankarr_"/>
    <language>en</language>
    <item>
      <title>JavaScript IIFE (Immediately Invoked Function Expression)</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Fri, 30 Jan 2026 07:31:32 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/javascript-iife-immediately-invoked-function-expression-4fak</link>
      <guid>https://forem.com/dash_suvankarr_/javascript-iife-immediately-invoked-function-expression-4fak</guid>
      <description>&lt;p&gt;What Is an IIFE in JavaScript?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An Immediately Invoked Function Expression (IIFE) is a function expression that executes immediately after it’s created. Its primary purpose is to create a private scope so variables don’t leak into the global environment.&lt;/li&gt;
&lt;li&gt;Before ES modules and block scope (let / const), IIFEs were one of the most reliable ways to write safe JavaScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basic IIFE Syntax:&lt;/p&gt;

&lt;p&gt;Classic IIFE:&lt;/p&gt;

&lt;p&gt;code:&lt;br&gt;
(function () {&lt;br&gt;
  const secret = 'hidden';&lt;br&gt;
  console.log('IIFE ran');&lt;br&gt;
})();&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The function is wrapped in parentheses → making it an expression&lt;/li&gt;
&lt;li&gt;() immediately invokes it&lt;/li&gt;
&lt;li&gt;Variables inside stay private&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Alternative IIFE Syntax:&lt;/p&gt;

&lt;p&gt;(function () { /&lt;em&gt;...&lt;/em&gt;/ }());&lt;br&gt;
!function () { /&lt;em&gt;...&lt;/em&gt;/ }();&lt;br&gt;
+function () { /&lt;em&gt;...&lt;/em&gt;/ }();&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All of these force JavaScript to treat the function as an expression.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;IIFE That Returns a Value:&lt;/p&gt;

&lt;p&gt;code:&lt;br&gt;
const result = (function (a, b) {&lt;br&gt;
  return a + b;&lt;br&gt;
})(2, 3);&lt;/p&gt;

&lt;p&gt;console.log(result); // 5&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Useful when you need a computed value without polluting scope.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Arrow Function IIFE:&lt;/p&gt;

&lt;p&gt;code:&lt;br&gt;
(() =&amp;gt; {&lt;br&gt;
  console.log('Arrow IIFE');&lt;br&gt;
})();&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Shorter and cleaner for simple logic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Async IIFE (Top-Level Await Alternative):&lt;/p&gt;

&lt;p&gt;code:&lt;br&gt;
(async function () {&lt;br&gt;
  const data = await fetch('/api/data').then(r =&amp;gt; r.json());&lt;br&gt;
  console.log(data);&lt;br&gt;
})();&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Ideal for environments without native top-level await.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Practical Use Cases:&lt;br&gt;
1️⃣ Encapsulation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep helper variables private.
2️⃣ One-Time Initialization:&lt;/li&gt;
&lt;li&gt;Feature detection, polyfills, event listeners.
3️⃣ Module Pattern:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;code:&lt;br&gt;
const Counter = (function () {&lt;br&gt;
  let count = 0;&lt;br&gt;
  return {&lt;br&gt;
    inc() { return ++count; },&lt;br&gt;
    get() { return count; }&lt;br&gt;
  };&lt;br&gt;
})();&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates private state with a public API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pitfalls &amp;amp; Best Practices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ Overusing IIFEs hurts readability&lt;/li&gt;
&lt;li&gt;⚠️ Can confuse beginners if undocumented&lt;/li&gt;
&lt;li&gt;✅ Prefer ES modules for modern apps&lt;/li&gt;
&lt;li&gt;✅ Use IIFEs mainly for:
          - Legacy scripts
          - One-off isolated logic
          - Immediate async setup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Quick Decision Guide:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Situation&lt;/th&gt;
&lt;th&gt;Recommendation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Legacy or single-file script&lt;/td&gt;
&lt;td&gt;Use IIFE&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Need private scope quickly&lt;/td&gt;
&lt;td&gt;Use IIFE&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modern app / bundler&lt;/td&gt;
&lt;td&gt;Use ES modules&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Understanding JavaScript Scope (With Examples)</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Fri, 30 Jan 2026 07:17:56 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/understanding-javascript-scope-with-examples-2cnb</link>
      <guid>https://forem.com/dash_suvankarr_/understanding-javascript-scope-with-examples-2cnb</guid>
      <description>&lt;p&gt;What Is Scope in JavaScript?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scope defines where variables and functions are visible and accessible in your code.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JavaScript scope rules directly affect safety, memory usage, and bug prevention.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Modern JavaScript has five key scope concepts you must understand.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;1️⃣ Global Scope:&lt;/p&gt;

&lt;p&gt;Definition:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables declared outside any function or block.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;code:&lt;br&gt;
var g = 1; // becomes window.g (browser)&lt;br&gt;
let h = 2; // global but not a window property&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;⚠️ Overusing global scope leads to name collisions and hard-to-debug issues.&lt;/li&gt;
&lt;li&gt;✅ Prefer modules for app-wide values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2️⃣ Block Scope:&lt;/p&gt;

&lt;p&gt;Definition:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Variables declared with let or const exist only inside { }.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;code:&lt;br&gt;
if (true) {&lt;br&gt;
  let x = 10;&lt;br&gt;
}&lt;br&gt;
console.log(x); // ReferenceError&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Best for loops, conditionals, and temporary values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3️⃣ Lexical Scope (Closures):&lt;/p&gt;

&lt;p&gt;Definition:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scope is determined by where variables/functions are written in the source code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;code:&lt;br&gt;
function makeCounter() {&lt;br&gt;
  let count = 0;&lt;br&gt;
  return () =&amp;gt; ++count;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;const counter = makeCounter();&lt;br&gt;
counter(); // 1&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Enables private state, encapsulation, and functional patterns.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4️⃣ Window Scope (Browser):&lt;/p&gt;

&lt;p&gt;Definition:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In browsers, window is the global object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;code:&lt;br&gt;
var a = 1;&lt;br&gt;
console.log(window.a); // 1&lt;/p&gt;

&lt;p&gt;let b = 2;&lt;br&gt;
console.log(window.b); // undefined&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;⚠️ Mostly legacy behavior — avoid in modern apps
.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5️⃣ Hoisting:&lt;/p&gt;

&lt;p&gt;Definition:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declarations are processed before execution.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;code:&lt;br&gt;
console.log(a); // undefined&lt;br&gt;
var a = 5;&lt;/p&gt;

&lt;p&gt;console.log(b); // ReferenceError&lt;br&gt;
let b = 6;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;var → hoisted + initialized&lt;/li&gt;
&lt;li&gt;let/const → hoisted but blocked by Temporal Dead Zone&lt;/li&gt;
&lt;/ul&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%2Fw2ol2964dttn7tf2hmrh.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%2Fw2ol2964dttn7tf2hmrh.png" alt=" " width="800" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;✅ Best Practices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prefer const → let → avoid var&lt;/li&gt;
&lt;li&gt;Never rely on implicit globals&lt;/li&gt;
&lt;li&gt;Use ES modules to isolate scope&lt;/li&gt;
&lt;li&gt;Read legacy code carefully due to hoisting&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>discuss</category>
    </item>
    <item>
      <title>How to Send JSON from JavaScript: Fetch, Axios, and Best Practices</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Fri, 30 Jan 2026 07:02:42 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/how-to-send-json-from-javascript-fetch-axios-and-best-practices-kia</link>
      <guid>https://forem.com/dash_suvankarr_/how-to-send-json-from-javascript-fetch-axios-and-best-practices-kia</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Sending JSON data from JavaScript to an API is one of the most common tasks in modern web development. Whether you’re submitting a form, creating a user, or saving data, the pattern is largely the same.&lt;/li&gt;
&lt;li&gt;This guide explains how to send JSON correctly, with examples using fetch, axios, and legacy APIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Quick Checklist Before Sending JSON:&lt;/p&gt;

&lt;p&gt;Serialize the object:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON.stringify(obj)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Set the correct header:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Content-Type: application/json&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Parse the response:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;response.json()&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Handle CORS:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Required for cross-origin browser requests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example 1: Sending JSON with Fetch (Modern Approach):&lt;/p&gt;

&lt;p&gt;async function createUser(user) {&lt;br&gt;
  const res = await fetch('&lt;a href="https://api.example.com/users" rel="noopener noreferrer"&gt;https://api.example.com/users&lt;/a&gt;', {&lt;br&gt;
    method: 'POST',&lt;br&gt;
    headers: {&lt;br&gt;
      'Content-Type': 'application/json'&lt;br&gt;
    },&lt;br&gt;
    body: JSON.stringify(user)&lt;br&gt;
  });&lt;/p&gt;

&lt;p&gt;if (!res.ok) {&lt;br&gt;
    throw new Error(&lt;code&gt;HTTP ${res.status}&lt;/code&gt;);&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;return await res.json();&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Usage:&lt;br&gt;
createUser({ name: 'Subhankar', city: 'Bhubaneswar' })&lt;br&gt;
  .then(user =&amp;gt; console.log('Created user id:', user.id))&lt;br&gt;
  .catch(console.error);&lt;/p&gt;

&lt;p&gt;Why Fetch?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Built into modern browsers and Node.js&lt;/li&gt;
&lt;li&gt;Promise-based&lt;/li&gt;
&lt;li&gt;Clean async/await syntax&lt;/li&gt;
&lt;li&gt;No external dependency&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example 2: Sending JSON with Axios:&lt;/p&gt;

&lt;p&gt;import axios from 'axios';&lt;/p&gt;

&lt;p&gt;async function createUser(user) {&lt;br&gt;
  const res = await axios.post(&lt;br&gt;
    '&lt;a href="https://api.example.com/users" rel="noopener noreferrer"&gt;https://api.example.com/users&lt;/a&gt;',&lt;br&gt;
    user&lt;br&gt;
  );&lt;br&gt;
  return res.data;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Why Axios?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automatically sets Content-Type&lt;/li&gt;
&lt;li&gt;Automatically parses JSON&lt;/li&gt;
&lt;li&gt;Supports interceptors and retries&lt;/li&gt;
&lt;li&gt;Easier testing and error handling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example 3: XMLHttpRequest (Legacy Support):&lt;/p&gt;

&lt;p&gt;const xhr = new XMLHttpRequest();&lt;br&gt;
xhr.open('POST', '/users');&lt;br&gt;
xhr.setRequestHeader('Content-Type', 'application/json');&lt;/p&gt;

&lt;p&gt;xhr.onload = () =&amp;gt; {&lt;br&gt;
  if (xhr.status &amp;gt;= 200 &amp;amp;&amp;amp; xhr.status &amp;lt; 300) {&lt;br&gt;
    const data = JSON.parse(xhr.responseText);&lt;br&gt;
    console.log(data);&lt;br&gt;
  }&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;xhr.send(JSON.stringify({ name: 'A' }));&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;⚠️ Use this only for very old browser support.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What the Server Receives:&lt;/p&gt;

&lt;p&gt;Headers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Content-Type: application/json&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Request Body:&lt;br&gt;
{&lt;br&gt;
  "name": "Subhankar",&lt;br&gt;
  "city": "Bhubaneswar"&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;In Node.js + Express, this is parsed using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;app.use(express.json());&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pitfalls &amp;amp; Best Practices:&lt;/p&gt;

&lt;p&gt;JSON.stringify Caveats:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ Functions are removed&lt;/li&gt;
&lt;li&gt;❌ undefined is ignored&lt;/li&gt;
&lt;li&gt;❌ Circular references throw errors
Use try/catch or custom serializers for complex objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CORS:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Browser requests to another origin require server 
headers:
code:
Access-Control-Allow-Origin&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Error Handling:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Always check response.ok&lt;/li&gt;
&lt;li&gt;Handle network failures separately&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Security:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never expose secrets in frontend code&lt;/li&gt;
&lt;li&gt;Always use HTTPS&lt;/li&gt;
&lt;li&gt;Validate data server-side&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Short Decision Guide:&lt;br&gt;
| Tool           | When to Use                      |&lt;br&gt;
| -------------- | -------------------------------- |&lt;br&gt;
| fetch          | Native, modern, lightweight      |&lt;br&gt;
| axios          | Cleaner code, auto JSON handling |&lt;br&gt;
| XMLHttpRequest | Legacy browser support           |&lt;/p&gt;

&lt;p&gt;Final Thoughts:&lt;/p&gt;

&lt;p&gt;Sending JSON correctly is less about syntax and more about discipline:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;headers, serialization, error handling, and security.&lt;/li&gt;
&lt;li&gt;Master this pattern once—and you’ll use it everywhere.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>discuss</category>
    </item>
    <item>
      <title>API and JSON Explained: How Data Moves Across the Web</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Fri, 30 Jan 2026 06:49:24 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/api-and-json-explained-how-data-moves-across-the-web-55mf</link>
      <guid>https://forem.com/dash_suvankarr_/api-and-json-explained-how-data-moves-across-the-web-55mf</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Modern web applications constantly exchange data—user profiles, weather updates, orders, analytics. Two core concepts make this possible: APIs and JSON.&lt;/li&gt;
&lt;li&gt;This article explains what they are, how they work together, and how to use them correctly in JavaScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What Is an API?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API stands for Application Programming Interface.&lt;/li&gt;
&lt;li&gt;It is a contract that defines how one program can request data or functionality from another.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An API specifies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Endpoints (URLs)&lt;/li&gt;
&lt;li&gt;HTTP methods (GET, POST, PUT, DELETE)&lt;/li&gt;
&lt;li&gt;Parameters&lt;/li&gt;
&lt;li&gt;Response format&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Common API Use Cases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetching remote data&lt;/li&gt;
&lt;li&gt;Submitting forms&lt;/li&gt;
&lt;li&gt;Authenticating users&lt;/li&gt;
&lt;li&gt;Integrating third-party services (payments, maps)&lt;/li&gt;
&lt;li&gt;Connecting frontend apps to backend services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What Is JSON?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JSON (JavaScript Object Notation) is a text-based, language-independent data format used to represent structured data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Objects&lt;/li&gt;
&lt;li&gt;Arrays&lt;/li&gt;
&lt;li&gt;Strings&lt;/li&gt;
&lt;li&gt;Numbers&lt;/li&gt;
&lt;li&gt;Booleans&lt;/li&gt;
&lt;li&gt;null&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why JSON Is So Popular:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lightweight and compact&lt;/li&gt;
&lt;li&gt;Human-readable&lt;/li&gt;
&lt;li&gt;Easy to parse&lt;/li&gt;
&lt;li&gt;Supported by nearly all programming languages
This makes JSON the default data format for web APIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How APIs and JSON Work Together:&lt;/p&gt;

&lt;p&gt;At a high level:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A client (browser or Node.js) calls an API endpoint&lt;/li&gt;
&lt;li&gt;GET /users/123&lt;/li&gt;
&lt;li&gt;The server responds with JSON&lt;/li&gt;
&lt;li&gt;{"id":123,"name":"Subhankar"}&lt;/li&gt;
&lt;li&gt;The client converts JSON into native objects and uses the data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JavaScript Examples:&lt;/p&gt;

&lt;p&gt;1️⃣ Fetching JSON from an API:&lt;/p&gt;

&lt;p&gt;async function getUser(id) {&lt;br&gt;
  const res = await fetch(&lt;code&gt;https://api.example.com/users/${id}&lt;/code&gt;);&lt;br&gt;
  if (!res.ok) throw new Error('Network error');&lt;br&gt;
  return await res.json(); // JSON → JS object&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;getUser(123)&lt;br&gt;
  .then(user =&amp;gt; console.log(user.name))&lt;br&gt;
  .catch(console.error);&lt;/p&gt;

&lt;p&gt;2️⃣ Sending JSON to an API:&lt;/p&gt;

&lt;p&gt;const newUser = { name: 'Subhankar', city: 'Bhubaneshwar' };&lt;/p&gt;

&lt;p&gt;fetch('&lt;a href="https://api.example.com/users" rel="noopener noreferrer"&gt;https://api.example.com/users&lt;/a&gt;', {&lt;br&gt;
  method: 'POST',&lt;br&gt;
  headers: { 'Content-Type': 'application/json' },&lt;br&gt;
  body: JSON.stringify(newUser) // JS object → JSON text&lt;br&gt;
})&lt;br&gt;
.then(res =&amp;gt; res.json())&lt;br&gt;
.then(data =&amp;gt; console.log('Created user ID:', data.id));&lt;/p&gt;

&lt;p&gt;3️⃣ Parsing JSON Safely:&lt;/p&gt;

&lt;p&gt;const jsonText = '{"a":1}';&lt;/p&gt;

&lt;p&gt;try {&lt;br&gt;
  const obj = JSON.parse(jsonText);&lt;br&gt;
  console.log(obj.a);&lt;br&gt;
} catch (err) {&lt;br&gt;
  console.error('Invalid JSON');&lt;br&gt;
}&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;⚠️ JSON.parse throws an error if the JSON is invalid—always handle safely.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Practical Tips &amp;amp; Pitfalls:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Always use HTTPS for API calls&lt;/li&gt;
&lt;li&gt;✅ Set Content-Type: application/json when sending JSON&lt;/li&gt;
&lt;li&gt;✅ Validate and sanitize untrusted API responses&lt;/li&gt;
&lt;li&gt;⚠️ Large payloads? Use pagination, compression, or streaming&lt;/li&gt;
&lt;li&gt;❌ Don’t assume JSON is safe—handle errors properly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Final Thoughts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;APIs define how systems talk.&lt;/li&gt;
&lt;li&gt;JSON defines what they say.&lt;/li&gt;
&lt;li&gt;Together, they form the backbone of modern web development. If you understand this pair well, everything from frontend apps to backend services becomes much easier to reason about.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Singleton vs Non-Singleton in JavaScript: When and Why to Use Each</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Fri, 30 Jan 2026 06:37:00 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/singleton-vs-non-singleton-in-javascript-when-and-why-to-use-each-3f6b</link>
      <guid>https://forem.com/dash_suvankarr_/singleton-vs-non-singleton-in-javascript-when-and-why-to-use-each-3f6b</guid>
      <description>&lt;p&gt;In JavaScript applications, object creation strategy directly affects maintainability, scalability, and testability. One common design decision is whether to use a singleton or a non-singleton object.&lt;/p&gt;

&lt;p&gt;This article breaks down the differences, use cases, and best practices with practical JavaScript examples.&lt;/p&gt;

&lt;p&gt;What Is a Singleton?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A singleton is an object designed so that only one instance exists across the entire application. Any request for that object returns the same instance.&lt;/li&gt;
&lt;li&gt;Singletons are commonly used for shared resources where multiple instances would be wasteful or harmful.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Characteristics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Single global instance&lt;/li&gt;
&lt;li&gt;Shared state across the app&lt;/li&gt;
&lt;li&gt;Controlled creation logic&lt;/li&gt;
&lt;li&gt;Harder to test if tightly coupled&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JavaScript Singleton Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In JavaScript, ES modules are singletons by default.
Ex:-
// config.js
const config = {
apiUrl: '&lt;a href="https://api.example.com" rel="noopener noreferrer"&gt;https://api.example.com&lt;/a&gt;',
timeout: 5000
};&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;export default config;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every import of config receives the same object instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Class-Based Singleton Example:&lt;/p&gt;

&lt;p&gt;class Logger {&lt;br&gt;
  constructor() {&lt;br&gt;
    if (Logger.instance) {&lt;br&gt;
      return Logger.instance;&lt;br&gt;
    }&lt;br&gt;
    this.logs = [];&lt;br&gt;
    Logger.instance = this;&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;log(msg) {&lt;br&gt;
    this.logs.push(msg);&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;export default Logger;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calling new Logger() multiple times always returns the same instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What Is a Non-Singleton?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A non-singleton is a regular object or class that allows multiple independent instances, each with its own state.&lt;/li&gt;
&lt;li&gt;This is the default behavior in most object-oriented designs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Characteristics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple instances allowed&lt;/li&gt;
&lt;li&gt;Instance-specific state&lt;/li&gt;
&lt;li&gt;Easy to test and mock&lt;/li&gt;
&lt;li&gt;Simple construction logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Non-Singleton Example:&lt;/p&gt;

&lt;p&gt;class User {&lt;br&gt;
  constructor(name) {&lt;br&gt;
    this.name = name;&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;const u1 = new User('A');&lt;br&gt;
const u2 = new User('B');&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each new User() call creates a separate object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Quick Comparison:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Attribute&lt;/th&gt;
&lt;th&gt;Singleton&lt;/th&gt;
&lt;th&gt;Non-Singleton&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Instance count&lt;/td&gt;
&lt;td&gt;One global instance&lt;/td&gt;
&lt;td&gt;Multiple instances&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use case&lt;/td&gt;
&lt;td&gt;Shared resources&lt;/td&gt;
&lt;td&gt;Domain entities&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;State&lt;/td&gt;
&lt;td&gt;Shared&lt;/td&gt;
&lt;td&gt;Isolated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Testability&lt;/td&gt;
&lt;td&gt;Harder&lt;/td&gt;
&lt;td&gt;Easier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Complexity&lt;/td&gt;
&lt;td&gt;Higher&lt;/td&gt;
&lt;td&gt;Lower&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;When to Use Each:&lt;/p&gt;

&lt;p&gt;Use Singleton When:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Managing shared resources (DB, logger)&lt;/li&gt;
&lt;li&gt;Centralizing app configuration&lt;/li&gt;
&lt;li&gt;Implementing caches or feature flags&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use Non-Singleton When:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating domain entities (users, orders)&lt;/li&gt;
&lt;li&gt;Building UI components&lt;/li&gt;
&lt;li&gt;Handling request-specific or temporary data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pitfalls &amp;amp; Best Practices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ Avoid overusing singletons—they introduce hidden global state&lt;/li&gt;
&lt;li&gt;❌ Don’t use singletons for domain models&lt;/li&gt;
&lt;li&gt;✅ Prefer dependency injection for better testability&lt;/li&gt;
&lt;li&gt;✅ In Node.js, rely on module exports for safe singletons&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Final Thoughts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Singletons are powerful—but dangerous when misused.&lt;/li&gt;
&lt;li&gt;Non-singletons are boring—but safe and scalable.&lt;/li&gt;
&lt;li&gt;The key is intentional design:&lt;/li&gt;
&lt;li&gt;Shared resource → Singleton&lt;/li&gt;
&lt;li&gt;Multiple entities → Non-Singleton&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>career</category>
    </item>
    <item>
      <title>Shallow Copy vs Deep Copy in JavaScript: A Practical Guide</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Fri, 30 Jan 2026 06:23:06 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/shallow-copy-vs-deep-copy-in-javascript-a-practical-guide-4c7n</link>
      <guid>https://forem.com/dash_suvankarr_/shallow-copy-vs-deep-copy-in-javascript-a-practical-guide-4c7n</guid>
      <description>&lt;p&gt;When working with arrays and objects in JavaScript, copying data incorrectly can lead to subtle and frustrating bugs. The root cause is often misunderstanding shallow copy versus deep copy.&lt;/p&gt;

&lt;p&gt;This guide explains the difference, when to use each, and the pitfalls to avoid.&lt;/p&gt;

&lt;p&gt;Understanding the Difference:&lt;br&gt;
Shallow Copy:&lt;/p&gt;

&lt;p&gt;A shallow copy creates a new array or object, but nested objects and arrays still reference the original memory.&lt;/p&gt;

&lt;p&gt;This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Changes to nested values affect both the copy and the original&lt;/li&gt;
&lt;li&gt;Only the top-level structure is duplicated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Deep Copy:&lt;/p&gt;

&lt;p&gt;A deep copy creates a fully independent duplicate of the original data structure, recursively copying all nested values.&lt;/p&gt;

&lt;p&gt;This ensures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No shared references&lt;/li&gt;
&lt;li&gt;Mutations do not affect the original data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When to Use Each:&lt;/p&gt;

&lt;p&gt;Use Shallow Copy When:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The array contains only primitives (numbers, strings, booleans)&lt;/li&gt;
&lt;li&gt;You don’t plan to mutate nested data&lt;/li&gt;
&lt;li&gt;Performance and memory usage matter&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use Deep Copy When:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data contains nested objects or arrays&lt;/li&gt;
&lt;li&gt;You need immutable updates (e.g., React state)&lt;/li&gt;
&lt;li&gt;You want full isolation between copies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JavaScript Examples:&lt;br&gt;
Shallow Copy Example:&lt;/p&gt;

&lt;p&gt;const a = [{ x: 1 }, { x: 2 }];&lt;br&gt;
const b = a.slice();   // shallow copy&lt;/p&gt;

&lt;p&gt;b[0].x = 99;&lt;br&gt;
console.log(a[0].x); // 99 (shared reference)&lt;/p&gt;

&lt;p&gt;Deep Copy Examples:&lt;/p&gt;

&lt;p&gt;JSON-based Deep Copy (JSON-safe data only)&lt;br&gt;
const deep1 = JSON.parse(JSON.stringify(a));&lt;/p&gt;

&lt;p&gt;Limitations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Loses Date, Map, Set&lt;/li&gt;
&lt;li&gt;Drops functions and undefined&lt;/li&gt;
&lt;li&gt;Cannot handle circular references&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Modern Built-in Deep Copy:&lt;br&gt;
const deep2 = structuredClone(a);&lt;/p&gt;

&lt;p&gt;Advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Preserves more data types&lt;/li&gt;
&lt;li&gt;Handles circular references&lt;/li&gt;
&lt;li&gt;Safer than JSON cloning&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Performance Considerations:&lt;br&gt;
Deep cloning large or complex structures is expensive. Instead of cloning everything:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clone only the part you intend to change&lt;/li&gt;
&lt;li&gt;Prefer shallow copy for flat data&lt;/li&gt;
&lt;li&gt;Use libraries like lodash.cloneDeep for complex cases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Practical Tips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrays of primitives → Shallow copy is enough&lt;/li&gt;
&lt;li&gt;Nested objects → Use deep copy&lt;/li&gt;
&lt;li&gt;Avoid JSON cloning when data types matter&lt;/li&gt;
&lt;li&gt;Always consider performance when deep cloning&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Final Thoughts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Many state-related bugs in JavaScript happen because of unintended shared references. Knowing when to use shallow or deep copy is a foundational skill—especially in modern frameworks like React.&lt;/li&gt;
&lt;li&gt;Mastering this concept will save you time, prevent bugs, and make your code more predictable.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Understanding __proto__ in JavaScript</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Thu, 29 Jan 2026 06:51:00 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/understanding-proto-in-javascript-3ea</link>
      <guid>https://forem.com/dash_suvankarr_/understanding-proto-in-javascript-3ea</guid>
      <description>&lt;p&gt;&lt;strong&gt;proto&lt;/strong&gt; is a legacy JavaScript accessor that exposes an object’s internal prototype reference ([[Prototype]]). This prototype link defines where JavaScript looks next when a property is not found directly on an object.&lt;/p&gt;

&lt;p&gt;Although obj.&lt;strong&gt;proto&lt;/strong&gt; is widely supported, changing it at runtime is not recommended. Modifying the prototype chain dynamically can degrade performance and interfere with JavaScript engine optimizations.&lt;/p&gt;

&lt;p&gt;Modern JavaScript provides safer, standard alternatives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Object.getPrototypeOf(obj) to read an object’s prototype&lt;/li&gt;
&lt;li&gt;Object.create(proto) to create objects with a specific prototype&lt;/li&gt;
&lt;li&gt;Object.setPrototypeOf(obj, proto) (use sparingly)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ex: -&lt;br&gt;
const proto = { greet() { return 'hi'; } };&lt;br&gt;
const obj = Object.create(proto);&lt;/p&gt;

&lt;p&gt;Object.getPrototypeOf(obj) === proto; // true&lt;/p&gt;

&lt;p&gt;Best practice: avoid using &lt;strong&gt;proto&lt;/strong&gt; directly—treat it as a debugging aid, not a design tool.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Stack vs Heap in JavaScript: A Practical Guide</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Thu, 29 Jan 2026 06:44:35 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/stack-vs-heap-in-javascript-a-practical-guide-5bnp</link>
      <guid>https://forem.com/dash_suvankarr_/stack-vs-heap-in-javascript-a-practical-guide-5bnp</guid>
      <description>&lt;p&gt;JavaScript automatically manages memory, but understanding how the stack and heap work can help developers avoid bugs, improve performance, and prevent memory leaks.&lt;/p&gt;

&lt;p&gt;Short Answer&lt;br&gt;
Primitives and function call frames are handled on the call stack.&lt;br&gt;
Objects and arrays live on the heap, with references stored on the stack.&lt;br&gt;
Memory allocation and cleanup are handled by garbage collection.&lt;br&gt;
This behavior is the same in browsers and Node.js.&lt;/p&gt;

&lt;p&gt;Stack vs Heap Comparison&lt;/p&gt;

&lt;p&gt;Aspect: -&lt;br&gt;
Stores&lt;br&gt;&lt;br&gt;
Access speed&lt;br&gt;
Lifetime&lt;br&gt;
Allocation&lt;/p&gt;

&lt;p&gt;Stack: -&lt;br&gt;
Call frames, primitives, references&lt;br&gt;
Fast&lt;br&gt;
Short (function execution)&lt;br&gt;
Automatic (LIFO)&lt;/p&gt;

&lt;p&gt;Heap: -&lt;br&gt;
Objects, arrays, functions&lt;br&gt;
Slower&lt;br&gt;
Long (until GC)&lt;br&gt;
Dynamic&lt;/p&gt;

&lt;p&gt;Understanding the Stack (Call Stack)&lt;br&gt;
The call stack stores:&lt;br&gt;
Function execution frames.&lt;br&gt;
Primitive values such as numbers, booleans, null, undefined, and symbols.&lt;br&gt;
When a function is called, a frame is pushed onto the stack. When it returns, the frame is popped.&lt;/p&gt;

&lt;p&gt;Understanding the Heap&lt;br&gt;
The heap stores:&lt;br&gt;
Objects&lt;br&gt;
Arrays&lt;br&gt;
Function objects&lt;br&gt;
When you create {} or [], JavaScript allocates memory on the heap and stores a reference to that object on the stack (or inside another object). The garbage collector frees heap memory when objects are no longer reachable.&lt;/p&gt;

&lt;p&gt;Reference vs Value Example&lt;br&gt;
// primitives copied by value&lt;br&gt;
let a = 10;&lt;br&gt;
let b = a;&lt;/p&gt;

&lt;p&gt;// objects copied by reference&lt;br&gt;
let obj1 = { x: 1 };&lt;br&gt;
let obj2 = obj1;&lt;br&gt;
obj2.x = 2;&lt;/p&gt;

&lt;p&gt;console.log(obj1.x); // 2&lt;/p&gt;

&lt;p&gt;Memory Management &amp;amp; Garbage Collection&lt;br&gt;
You cannot manually free memory in JavaScript. Modern engines automatically reclaim heap memory when objects become unreachable.&lt;/p&gt;

&lt;p&gt;🚨 Common risk: memory leaks caused by lingering references&lt;br&gt;
✅ Best practice: remove references to large objects when no longer needed&lt;/p&gt;

&lt;p&gt;File Access in JavaScript&lt;br&gt;
Browser&lt;br&gt;
No direct file-system access&lt;br&gt;
Uses File API or File System Access API&lt;br&gt;
Always user-mediated and asynchronous&lt;/p&gt;

&lt;p&gt;Ex: -&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;document.querySelector('input').addEventListener('change', e =&amp;gt; {&lt;br&gt;
    const file = e.target.files[0];&lt;br&gt;
    file.text().then(console.log);&lt;br&gt;
  });&lt;/p&gt;

&lt;p&gt;Node.js&lt;br&gt;
Full file-system access via fs&lt;br&gt;
Same V8 engine with stack/heap semantics&lt;/p&gt;

&lt;p&gt;Ex: -&lt;br&gt;
const fs = require('fs');&lt;/p&gt;

&lt;p&gt;fs.readFile('./data.txt', 'utf8', (err, data) =&amp;gt; {&lt;br&gt;
  if (err) throw err;&lt;br&gt;
  console.log(data);&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;Practical Tips&lt;br&gt;
Avoid large global variables&lt;br&gt;
Use streams for large files in Node.js&lt;br&gt;
Profile memory using Chrome DevTools or Node Inspector&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding Truthy and Falsy Values in JavaScript</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Thu, 29 Jan 2026 06:29:25 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/understanding-truthy-and-falsy-values-in-javascript-3c9m</link>
      <guid>https://forem.com/dash_suvankarr_/understanding-truthy-and-falsy-values-in-javascript-3c9m</guid>
      <description>&lt;p&gt;In JavaScript, values are often evaluated in Boolean contexts such as if statements, logical expressions, and loops. Rather than requiring strict true or false, JavaScript converts values into truthy or falsy.&lt;/p&gt;

&lt;p&gt;Definition&lt;/p&gt;

&lt;p&gt;Truthy values evaluate to true.&lt;br&gt;
Falsy values evaluate to false.&lt;br&gt;
JavaScript defines a limited set of falsy values; every other value is truthy.&lt;br&gt;
Falsy Values.&lt;/p&gt;

&lt;p&gt;The following values always evaluate to false:&lt;br&gt;
false&lt;br&gt;
0, -0&lt;br&gt;
0n&lt;br&gt;
"" (empty string)&lt;br&gt;
null&lt;br&gt;
undefined&lt;br&gt;
NaN&lt;/p&gt;

&lt;p&gt;Boolean(false);      // false&lt;br&gt;
Boolean(0);          // false&lt;br&gt;
Boolean("");         // false&lt;br&gt;
Boolean(null);       // false&lt;/p&gt;

&lt;p&gt;Example in an if statement:&lt;br&gt;
let value = "";&lt;br&gt;
if (value) {&lt;br&gt;
  console.log("runs");&lt;br&gt;
} else {&lt;br&gt;
  console.log("does not run");&lt;br&gt;
}&lt;br&gt;
Truthy Values&lt;/p&gt;

&lt;p&gt;Truthy values include:&lt;br&gt;
Non-zero numbers&lt;br&gt;
Non-empty strings&lt;/p&gt;

&lt;p&gt;Arrays, objects, and functions&lt;br&gt;
Boolean(1);           // true&lt;br&gt;
Boolean("hello");     // true&lt;br&gt;
Boolean([]);          // true&lt;br&gt;
Boolean({});          // true&lt;/p&gt;

&lt;p&gt;if ("hello") {&lt;br&gt;
  console.log("This runs because non-empty strings are truthy");&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Logical Operators in Practice&lt;br&gt;
OR (||) returns the first truthy value:&lt;br&gt;
"" || "default";   // "default"&lt;br&gt;
AND (&amp;amp;&amp;amp;) returns the first falsy value or the last value:&lt;br&gt;
"ok" &amp;amp;&amp;amp; "done";    // "done"&lt;br&gt;
0 &amp;amp;&amp;amp; "no";         // 0&lt;/p&gt;

&lt;p&gt;Common Pitfalls and Best Practices&lt;br&gt;
"0" is truthy because it’s a non-empty string&lt;br&gt;
NaN is falsy, but typeof NaN === "number"&lt;br&gt;
Use Number.isNaN() to check for NaN&lt;br&gt;
Use explicit checks when exact behavior matters:&lt;br&gt;
value === ""&lt;br&gt;
value == null (checks both null and undefined)&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Mastering JavaScript String Methods</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Thu, 29 Jan 2026 06:15:10 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/mastering-javascript-string-methods-1oc5</link>
      <guid>https://forem.com/dash_suvankarr_/mastering-javascript-string-methods-1oc5</guid>
      <description>&lt;p&gt;JavaScript string methods are powerful built-in functions that allow developers to work efficiently with text. They are widely used for input validation, text formatting, parsing content, and building interactive user interfaces.&lt;/p&gt;

&lt;p&gt;Popular methods such as length, slice(), indexOf(), includes(), split(), replace() / replaceAll(), trim(), toLowerCase(), and toUpperCase() simplify common text-handling tasks.&lt;/p&gt;

&lt;p&gt;One important concept to understand is that strings in JavaScript are immutable. This means string methods do not modify the original value—instead, they return a new string or result.&lt;/p&gt;

&lt;p&gt;Practical Example&lt;/p&gt;

&lt;p&gt;const title = " Eng Lesson 1: Greetings ";&lt;/p&gt;

&lt;p&gt;const clean = title.trim();                 // Remove extra spaces&lt;br&gt;
const lower = clean.toLowerCase();           // Convert to lowercase&lt;br&gt;
const hasEng = lower.includes("eng");        // Case-insensitive check&lt;br&gt;
const short = clean.slice(0, 12);            // Extract a portion&lt;br&gt;
const safe = clean.replaceAll("Lesson", "Unit");&lt;/p&gt;

&lt;p&gt;console.log({ clean, lower, hasEng, short, safe });&lt;/p&gt;

&lt;p&gt;Best Practices&lt;/p&gt;

&lt;p&gt;Always sanitize user input using trim()&lt;/p&gt;

&lt;p&gt;Use toLowerCase() for reliable comparisons&lt;/p&gt;

&lt;p&gt;Prefer replaceAll() when updating repeated text&lt;/p&gt;

&lt;p&gt;Test with real Unicode data for edge cases&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>React Function Components: The Future of UI Starts Here</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Fri, 23 Jan 2026 07:07:51 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/react-function-components-the-future-of-ui-starts-here-2mog</link>
      <guid>https://forem.com/dash_suvankarr_/react-function-components-the-future-of-ui-starts-here-2mog</guid>
      <description>&lt;p&gt;Lightweight JS functions that return UI. Use hooks for state &amp;amp; effects. Faster, reusable, cleaner structure for building modern React apps.&lt;br&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%2Frjn3nys1bs77xpik2cip.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frjn3nys1bs77xpik2cip.jpg" alt=" " width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>react</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Edge-Powered Server Actions: The Future of React/Next.js Backends</title>
      <dc:creator>Suvankarr Dash</dc:creator>
      <pubDate>Fri, 23 Jan 2026 07:03:01 +0000</pubDate>
      <link>https://forem.com/dash_suvankarr_/edge-powered-server-actions-the-future-of-reactnextjs-backends-4jh4</link>
      <guid>https://forem.com/dash_suvankarr_/edge-powered-server-actions-the-future-of-reactnextjs-backends-4jh4</guid>
      <description>&lt;p&gt;Modern JS is server-first and reactive: RSC reduces client JS, Signals boost UI speed, and Next.js 15 improves routing, caching, and performance.&lt;br&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%2F4sz7bb52laksgwos0tps.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4sz7bb52laksgwos0tps.jpg" alt=" " width="800" height="1200"&gt;&lt;/a&gt;&lt;br&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%2Fe6ocg2o4ragr27k4cazw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6ocg2o4ragr27k4cazw.jpg" alt=" " width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>react</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
