<?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: Md Imran Hossen Akash</title>
    <description>The latest articles on DEV Community by Md Imran Hossen Akash (@m_im_ha).</description>
    <link>https://dev.to/m_im_ha</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%2F1766504%2F9688d4db-7119-4d6b-a926-ad97cf8dfe09.jpg</url>
      <title>DEV Community: Md Imran Hossen Akash</title>
      <link>https://dev.to/m_im_ha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/m_im_ha"/>
    <language>en</language>
    <item>
      <title>JavaScript’s Map is Better Than Object 🤔❓</title>
      <dc:creator>Md Imran Hossen Akash</dc:creator>
      <pubDate>Mon, 14 Jul 2025 12:06:20 +0000</pubDate>
      <link>https://dev.to/m_im_ha/javascripts-map-is-better-than-object-2i4o</link>
      <guid>https://dev.to/m_im_ha/javascripts-map-is-better-than-object-2i4o</guid>
      <description>&lt;p&gt;When managing key-value pairs in JavaScript, you might default to using a plain Object. But the Map object, introduced in ES6, often outshines Object in flexibility and functionality. Here’s why you should consider Map for your next project ⬇️:&lt;/p&gt;

&lt;p&gt;1️⃣ Unlike Object, which converts keys to strings, Map allows any value as a key-objects, functions, numbers, or even undefined. This makes Map ideal for complex data structures.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const map = new Map();
const objKey = { id: 1 };
map.set(objKey, "User Data");
console.log(map.get(objKey)); // "User Data"
const obj = {};
obj[objKey] = "User Data";
console.log(obj[objKey]); // "User Data" (but key collision risk)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2️⃣ Map has a built-in .size property to easily check the number of entries, while Object requires Object.keys(obj).length, which is less convenient and slower for large datasets.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const map = new Map([["a", 1], ["b", 2]]);
console.log(map.size); // 2
const obj = { a: 1, b: 2 };
console.log(Object.keys(obj).length); // 2 (more verbose)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3️⃣ Object keys are prone to collisions since they’re coerced to strings. Map avoids this by preserving the exact key reference, ensuring reliable key-value mappings.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const obj = {};
obj["1"] = "String One";
obj[1] = "Number One"; // Overwrites because 1 becomes "1"
console.log(obj["1"]); // "Number One"
const map = new Map();
map.set("1", "String One");
map.set(1, "Number One");
console.log(map.get("1")); // "String One"
console.log(map.get(1)); // "Number One"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4️⃣ Map offers built-in methods like .forEach, .keys(), .values(), and .entries() for seamless iteration. With Object, you need extra steps to iterate over keys or values.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const map = new Map([["name", "Alice"], ["age", 30]]);
map.forEach((value, key) =&amp;gt; console.log(`${key}: ${value}`));
// Output: name: Alice, age: 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5️⃣ Adding or removing key-value pairs in a Map is optimized for frequent updates. With Object, operations like delete or property checks can be less efficient, especially with large datasets.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const map = new Map();
map.set("key", "value");
map.delete("key"); // Fast and clean
const obj = { key: "value" };
delete obj.key; // Works, but less optimized for frequent changes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6️⃣ Object inherits properties from Object.prototype, which can cause unexpected behavior (e.g., toString). Map is free from prototype pollution, keeping your data clean.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const obj = { toString: "Custom" };
console.log(obj.toString); // "Custom" (overrides prototype)
const map = new Map([["toString", "Custom"]]);
console.log(map.get("toString")); // "Custom" (no conflict)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When to Use Map❓&lt;br&gt;
Choose Map when you need flexible keys, frequent updates, or clean iteration. Stick with Object for simple, static data or when JSON compatibility is key. Both have their place, but Map shines in dynamic, complex scenarios.&lt;/p&gt;

&lt;p&gt;Share your thoughts below 💬! &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Hidden Gem TypeScript Concepts to Supercharge Your Code</title>
      <dc:creator>Md Imran Hossen Akash</dc:creator>
      <pubDate>Tue, 08 Jul 2025 03:36:25 +0000</pubDate>
      <link>https://dev.to/m_im_ha/hidden-gem-typescript-concepts-to-supercharge-your-code-2kci</link>
      <guid>https://dev.to/m_im_ha/hidden-gem-typescript-concepts-to-supercharge-your-code-2kci</guid>
      <description>&lt;p&gt;TypeScript is packed with features that make coding more robust and enjoyable. While many focus on types and interfaces, here are some lesser-known TypeScript concepts that can transform how you write code. Let’s dive into these hidden gems ⬇️!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. never Type 💎
&lt;/h2&gt;

&lt;p&gt;The never type represents values that never occur, like functions that throw errors or never return. It’s great for exhaustive checks in unions.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function fail(message: string): never {
 throw new Error(message);
}

type Shape = "circle" | "square";
function getShape(shape: Shape) {
 switch (shape) {
 case "circle": return "Round";
 case "square": return "Square";
 default: const _exhaustiveCheck: never = shape;
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. unknown Type 💎
&lt;/h2&gt;

&lt;p&gt;Unlike any, the unknown type is a safer alternative for values with unknown types. You must narrow it before using, ensuring type safety.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function processData(data: unknown) {
 if (typeof data === "string") {
 console.log(data.toUpperCase());
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Index Signatures 💎
&lt;/h2&gt;

&lt;p&gt;Index signatures allow you to define types for objects with dynamic keys, perfect for scenarios like dictionaries or API responses.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

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

}
const scores: Dictionary = { math: 95, science: 88 };
console.log(scores["math"]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. as const Assertion 💎
&lt;/h2&gt;

&lt;p&gt;The as const assertion makes literals and objects read-only and narrows them to their exact values, enabling precise type inference.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const colors = ["red", "blue", "green"] as const;
type Color = typeof colors[number]; // "red" | "blue" | "green"
let favorite: Color = "red"; // Valid
favorite = "yellow"; // Error
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Keyof Type Operator 💎
&lt;/h2&gt;

&lt;p&gt;The keyof operator extracts the keys of a type as a union of string literals, ideal for type-safe property access.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface User {
 name: string;
 age: number;
}
type UserKeys = keyof User; // "name" | "age"
function getProperty(user: User, key: UserKeys) {
 return user[key];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. Type Inference with typeof 💎
&lt;/h2&gt;

&lt;p&gt;TypeScript’s typeof operator lets you extract types from values, making it easier to reuse existing structures without manual type definitions.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const config = { apiKey: "abc123", timeout: 5000 };
type ConfigType = typeof config; // { apiKey: string; timeout: number }
const newConfig: ConfigType = { apiKey: "xyz789", timeout: 3000 }; // Valid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why These Matter 🤔&lt;/strong&gt;&lt;br&gt;
These concepts add precision and flexibility to your TypeScript projects, helping you handle edge cases, dynamic data, and complex logic with confidence. They’re especially useful for building scalable apps or working with unpredictable inputs.&lt;br&gt;
Try these out in the TypeScript Playground or your next project. Which TypeScript feature has surprised you lately, or which of these are you eager to explore? Let’s geek out in the comments! 🚀&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>frontend</category>
      <category>softwaredevelopment</category>
      <category>webdev</category>
    </item>
    <item>
      <title>⚡Practical TypeScript Concepts to Enhance Your Code⚡</title>
      <dc:creator>Md Imran Hossen Akash</dc:creator>
      <pubDate>Mon, 07 Jul 2025 06:02:25 +0000</pubDate>
      <link>https://dev.to/m_im_ha/practical-typescript-concepts-to-enhance-your-code-453e</link>
      <guid>https://dev.to/m_im_ha/practical-typescript-concepts-to-enhance-your-code-453e</guid>
      <description>&lt;p&gt;TypeScript’s versatility makes it a must-have for modern developers. Beyond the basics, here are some practical TypeScript concepts that can streamline your workflow and make your code more robust. Let’s explore!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Type Assertions 🌟&lt;br&gt;
Type assertions let you tell TypeScript you know more about a value’s type than it can infer. Use them wisely to bypass type errors when you’re certain of the type.&lt;br&gt;
Example:&lt;br&gt;
&lt;code&gt;let input = document.getElementById("myInput") as HTMLInputElement;&lt;br&gt;
input.value = "Hello";&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Non-null Assertion Operator 🌟&lt;br&gt;
The non-null assertion operator (!) tells TypeScript a value is definitely not null or undefined, reducing unnecessary checks when you’re confident.&lt;br&gt;
Example:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let userName: string | null = "Alice";
console.log(userName!.toUpperCase());
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Discriminated Unions 🌟
Discriminated unions use a common property (the discriminant) to narrow types in a union, making complex type logic safer and more readable.
Example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Circle { kind: "circle"; radius: number }
interface Square { kind: "square"; side: number }
type Shape = Circle | Square;

function getArea(shape: Shape) {
 switch (shape.kind) {
 case "circle": return Math.PI * shape.radius ** 2;
 case "square": return shape.side ** 2;
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Type Guards 🌟
Type guards are functions or checks that narrow a type within a specific scope, improving type safety in dynamic scenarios.
Example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function isString(value: unknown): value is string {
 return typeof value === "string";
}

function process(value: unknown) {
 if (isString(value)) {
 console.log(value.toUpperCase());
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Module Augmentation 🌟
Module augmentation lets you extend existing modules (like third-party libraries) without modifying their source, adding custom types or functionality.
Example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;declare module "express" {
 interface Request {
 userId?: string;
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Literal Types 🌟
Literal types restrict a value to specific literals (e.g., "success" or 42), enabling precise type definitions for constants or states.
Example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Status = "success" | "error" | "loading";
let currentStatus: Status = "success";
currentStatus = "pending";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why These Concepts Rock⬇️&lt;br&gt;
These features make TypeScript more flexible and expressive, helping you handle real-world scenarios like third-party integrations, dynamic data, or strict state management. They’re practical tools for writing cleaner, safer code.&lt;br&gt;
Try It Out!. Play with these concepts in the TypeScript Playground or your next project. What’s a TypeScript feature you’ve found super handy, or which of these are you excited to use? Share your thoughts below!💬&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>typescript</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
