<?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: Shivam Sahu</title>
    <description>The latest articles on DEV Community by Shivam Sahu (@shivam_sahu_704d021337aec).</description>
    <link>https://dev.to/shivam_sahu_704d021337aec</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%2F1593440%2Fa34e4c2b-d957-41e6-b8c6-537de5846502.jpg</url>
      <title>DEV Community: Shivam Sahu</title>
      <link>https://dev.to/shivam_sahu_704d021337aec</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shivam_sahu_704d021337aec"/>
    <language>en</language>
    <item>
      <title>Async/Await : Zero to Hero 🚀</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Wed, 16 Apr 2025 13:27:34 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/async-await-full-18a8</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/async-await-full-18a8</guid>
      <description>&lt;h2&gt;
  
  
  Why async/await in Angular ? 🤔
&lt;/h2&gt;

&lt;p&gt;In Angular, many tasks, like fetching data from a server, can take time.&lt;br&gt;
Normally, we use .subscribe() for handling these tasks, but it can get messy when we have to chain many steps or make the code look messy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;this.apiService.getData().subscribe(response =&amp;gt; {
  console.log('First API Response:', response);

  this.apiService.getMoreData(response.id).subscribe(moreResponse =&amp;gt; {
    console.log('Second API Response:', moreResponse);

    this.apiService.getDetails(moreResponse.detailId).subscribe(detailResponse =&amp;gt; {
      console.log('Third API Response:', detailResponse);
    });
  });
});

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

&lt;/div&gt;



&lt;p&gt;That's where async and await come in! They help us handle these tasks in a much cleaner, easier-to-read way.&lt;br&gt;
&lt;/p&gt;

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

async fetchData() {
  try {
    const response = await firstValueFrom(this.apiService.getData());
    console.log('First API Response:', response);

    const moreResponse = await firstValueFrom(this.apiService.getMoreData(response.id));
    console.log('Second API Response:', moreResponse);

    const detailResponse = await firstValueFrom(this.apiService.getDetails(moreResponse.detailId));
    console.log('Third API Response:', detailResponse);
  } catch (error) {
    console.error('Error occurred:', error);
  }
}

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

&lt;/div&gt;



&lt;p&gt;With async/await, the code runs one step at a time without getting messy. It’s easy to read, easy to fix if something goes wrong, and you can catch all errors in one place. Even though it works in the background, the code looks simple and clean.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is async/await in Angular ? 📚
&lt;/h2&gt;

&lt;p&gt;async is a keyword that we put in front of a function to tell it, &lt;/p&gt;

&lt;p&gt;'Hey, this function is going to handle something that takes time.'&lt;/p&gt;

&lt;p&gt;And await is used inside that function to wait for something to finish before moving to the next line of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async getData() {
  const result = await this.http.get('https://api.example.com/users').toPromise();
  console.log(result);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, await tells Angular to wait for the data before moving forward. &lt;/p&gt;

&lt;p&gt;Without await, the code would keep running without waiting for the response, which might cause issues.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use async/await in Angular ? 🔧
&lt;/h2&gt;

&lt;p&gt;Step 1: Add async to your function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async ngOnInit() {
  // your code here
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2: Use await inside the function to wait for something.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async ngOnInit() {
  const data = await this.http.get('/api/data').toPromise();
  console.log(data);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: If you’re using HttpClient, make sure to convert the Observable to a Promise (use .toPromise() or firstValueFrom()).&lt;br&gt;
&lt;/p&gt;

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

async getData() {
  const data = await firstValueFrom(this.http.get('/api/data'));
  console.log(data);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Real-world example ? 🌍
&lt;/h2&gt;

&lt;p&gt;A practical use of async/await is in dependent dropdowns. For example, when a user selects a country, we need to fetch the states related to that country from the server.&lt;/p&gt;

&lt;p&gt;Using async/await, we can wait for the states to load first, and only then populate the next dropdown, ensuring a smooth user experience without race conditions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async onCountryChange(countryId: number) {
  this.states = await this.locationService.getStatesByCountry(countryId);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Avoid mistakes when using async/await ? ⚠️
&lt;/h2&gt;

&lt;p&gt;❌ Don't use await outside an async function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ngOnInit() {
  const user = await this.userService.getUser(); // ❌ Error: 'await' is only valid in async functions
  console.log(user);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Correct: Mark the function async&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async ngOnInit() {
  const user = await this.userService.getUser(); 
  console.log(user);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;❌ Don't mix await with subscribe() from RxJS. Use firstValueFrom() to convert Observables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async fetchData() {
  const data = await this.apiService.getData().subscribe(response =&amp;gt; {
    console.log(response);
  });
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Correct: Use firstValueFrom()&lt;br&gt;
&lt;/p&gt;

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

async getData() {
  const data = await firstValueFrom(this.apiService.getData());
  console.log(data);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;❌ Avoid unhandled try/catch. Always catch errors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async fetchData() {
  const data = await firstValueFrom(this.apiService.getData());
  console.log(data); // ❌ If API fails, app crashes without handling error
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Correct: With try/catch (proper error handling)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async fetchData() {
  try {
    const data = await firstValueFrom(this.apiService.getData());
    console.log(data);
  } catch (error) {
    console.error('Failed to fetch data:', error); // ✅ Graceful error handling
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;❌ Avoid using too many sequential await calls if they can be parallelized (performance hit).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async loadDashboard() {
  const profile = await firstValueFrom(this.apiService.getProfile());
  const notifications = await firstValueFrom(this.apiService.getNotifications());
  const messages = await firstValueFrom(this.apiService.getMessages());

  console.log(profile, notifications, messages);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Correct: Parallel await calls using Promise.all() (better performance)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;async loadDashboard() {
  const [profile, notifications, messages] = await Promise.all([
    firstValueFrom(this.apiService.getProfile()),
    firstValueFrom(this.apiService.getNotifications()),
    firstValueFrom(this.apiService.getMessages())
  ]);

  console.log(profile, notifications, messages);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Most asked interview question on async/await ? 🎯
&lt;/h2&gt;

&lt;p&gt;🔹 Basic Questions&lt;br&gt;
1️⃣ What is async/await in JavaScript/TypeScript?&lt;br&gt;
👉 Async/await is syntax to handle promises in a cleaner and more readable way, making asynchronous code behave like synchronous code.&lt;/p&gt;

&lt;p&gt;2️⃣ Why do we use async/await instead of .then()?&lt;br&gt;
👉 Async/await avoids nested .then() chains and makes error handling with try-catch much simpler.&lt;/p&gt;

&lt;p&gt;3️⃣ What does the async keyword do?&lt;br&gt;
👉 It marks a function to always return a promise, even if it returns a simple value.&lt;/p&gt;

&lt;p&gt;4️⃣ What does the await keyword do?&lt;br&gt;
👉 It pauses the function execution until the awaited promise is resolved or rejected.&lt;/p&gt;

&lt;p&gt;🔹 Angular-Specific Questions&lt;br&gt;
5️⃣ Where would you typically use async/await inside an Angular application?&lt;br&gt;
👉 In services while calling APIs, in component lifecycle methods (like ngOnInit), and during sequential operations like login ➡️ fetch profile ➡️ load dashboard.&lt;/p&gt;

&lt;p&gt;6️⃣ Can we use async/await with HttpClient in Angular?&lt;br&gt;
👉 Yes, but since HttpClient returns Observables, we often convert them to promises using .toPromise() (deprecated) or firstValueFrom() before using await.&lt;/p&gt;

&lt;p&gt;7️⃣ Can we use async/await inside Angular services?&lt;br&gt;
👉 Absolutely, services are a common place to write reusable async functions.&lt;/p&gt;

&lt;p&gt;🔹 Practical Scenario-Based Questions&lt;br&gt;
8️⃣ How would you handle multiple API calls using async/await?&lt;br&gt;
👉 Either:&lt;/p&gt;

&lt;p&gt;Wait one after another (sequentially)&lt;/p&gt;

&lt;p&gt;Or use Promise.all() if APIs are independent and can run in parallel.&lt;/p&gt;

&lt;p&gt;9️⃣ What happens if a promise fails inside an async function?&lt;br&gt;
👉 It throws an exception, which we should catch using a try-catch block.&lt;/p&gt;

&lt;p&gt;🔟 Can we use async/await inside Angular interceptors?&lt;br&gt;
👉 Yes, interceptors can be async if you return a promise that eventually resolves to an HTTP response.&lt;/p&gt;

&lt;p&gt;🔹 Slightly Advanced Questions&lt;br&gt;
1️⃣1️⃣ What are the drawbacks of async/await?&lt;br&gt;
👉&lt;/p&gt;

&lt;p&gt;You cannot run operations in parallel easily without Promise.all().&lt;/p&gt;

&lt;p&gt;If many awaits happen sequentially, it can slow down performance.&lt;/p&gt;

&lt;p&gt;Error handling can become tricky if you await multiple things without a proper structure.&lt;/p&gt;

&lt;p&gt;1️⃣2️⃣ Can you combine async/await and Observables?&lt;br&gt;
👉 Yes!&lt;br&gt;
We usually convert Observables to Promises if we want to use async/await.&lt;br&gt;
Example:&lt;/p&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy&lt;br&gt;
Edit&lt;br&gt;
await firstValueFrom(this.api.getData());&lt;br&gt;
🔹 Bonus: Real-Life Use Case Questions&lt;br&gt;
1️⃣3️⃣ Give one real-world example where async/await helped improve user experience in your project.&lt;br&gt;
👉 Example:&lt;/p&gt;

&lt;p&gt;Dependent dropdowns (country → states)&lt;/p&gt;

&lt;p&gt;File upload before navigation&lt;/p&gt;

&lt;p&gt;Token refresh before API calls&lt;/p&gt;

&lt;p&gt;1️⃣4️⃣ How would you handle an API retry if the awaited call fails?&lt;br&gt;
👉 Inside catch block, you can retry the call manually, or use retry strategies with services.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>interview</category>
    </item>
    <item>
      <title>angular inspiration yt channel</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Mon, 20 Jan 2025 05:50:56 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/angular-inspiration-yt-channel-4363</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/angular-inspiration-yt-channel-4363</guid>
      <description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=edR6Az7shv8&amp;amp;t=371s" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=edR6Az7shv8&amp;amp;t=371s&lt;/a&gt;&lt;/p&gt;

</description>
      <category>angular</category>
    </item>
    <item>
      <title>trending video topic angular</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Tue, 19 Nov 2024 05:57:35 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/trending-video-topic-angular-ghe</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/trending-video-topic-angular-ghe</guid>
      <description>&lt;p&gt;&lt;a href="https://chatgpt.com/share/673b7f9a-9a0c-8008-8ba0-afb3670e3cb8" rel="noopener noreferrer"&gt;https://chatgpt.com/share/673b7f9a-9a0c-8008-8ba0-afb3670e3cb8&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chatgpt.com/c/673c22d8-a43c-8007-b4bc-e4e330280b68" rel="noopener noreferrer"&gt;https://chatgpt.com/c/673c22d8-a43c-8007-b4bc-e4e330280b68&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>project through chatgpt</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Sun, 17 Nov 2024 15:18:45 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/project-through-chatgpt-ekh</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/project-through-chatgpt-ekh</guid>
      <description>&lt;p&gt;&lt;a href="https://chatgpt.com/c/673b5b4a-6ca8-8007-98c2-135f3491d347" rel="noopener noreferrer"&gt;https://chatgpt.com/c/673b5b4a-6ca8-8007-98c2-135f3491d347&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>async await hindi script</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Wed, 13 Nov 2024 05:19:00 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/async-await-hindi-script-31fc</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/async-await-hindi-script-31fc</guid>
      <description>&lt;p&gt;&lt;a href="https://chatgpt.com/c/67335967-dc14-8007-8301-240c33f8c007" rel="noopener noreferrer"&gt;https://chatgpt.com/c/67335967-dc14-8007-8301-240c33f8c007&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[Opening Scene]&lt;br&gt;
[Background Music] [Camera on Host]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
आज हम बात करेंगे TypeScript में async/await के बारे में। &lt;br&gt;
aaj ham एक aise tool k baare mai discuss krenge जो आपकी asynchronous programming की saari problem ka solution nikal सकता है! 🚀 अगर आप callback hell से बाहर निकलना चाहते हैं या अपने promises को बेहतर तरीके से हैंडल करना चाहते हैं, ya अपने कोड को ज्यादा readable और maintainable बनाना चाहते हैं, तो ये वीडियो आपके लिए है। इस वीडियो में हम async/await के हर scenario को detail mai समझेंगे, और साथ mai  real-world examples भी discuss krenge। तो चलिए, शुरू करते हैं!&lt;/p&gt;

&lt;p&gt;[Scene 1: Synchronous vs Asynchronous code]&lt;/p&gt;

&lt;p&gt;pahle ham baat krte hai synchronous and asynchronous code kaam kaise krte hai. dosto yah bahut important point hai isko dhyan se samjhna.&lt;/p&gt;

&lt;p&gt;console.log("Start");&lt;br&gt;
console.log("Processing...");&lt;br&gt;
console.log("End");&lt;/p&gt;

&lt;p&gt;Output comes in a sequence: "Start", "Processing...", "End".&lt;/p&gt;

&lt;p&gt;aap screen mai dekh sakte hai yah ak synchronous code hai.&lt;br&gt;
dosto synchronous code line by line execute hote hai.&lt;/p&gt;
&lt;h2&gt;
  
  
  यहां हम देख सकते हैं, पहले 'Start' print होगा, फिर 'Processing...' और last में 'End'. इस तरह, एक line दूसरे line के बाद ही execute hoti है।
&lt;/h2&gt;

&lt;p&gt;console.log("Start");&lt;/p&gt;

&lt;p&gt;setTimeout(() =&amp;gt; {&lt;br&gt;
  console.log("Processing...");&lt;br&gt;
}, 2000);&lt;/p&gt;

&lt;p&gt;console.log("End");&lt;/p&gt;

&lt;p&gt;Output is: "Start", "End", "Processing..." (after 2 seconds).&lt;/p&gt;

&lt;p&gt;Ab hamne dosto sychronous code ko asynchronous code mai convert kiya hai aap asynchronous code screen per dekh sakte hai. &lt;/p&gt;

&lt;p&gt;तो dekhiye dosto yah per 'End' पहले print hoga और phir 'Processing...' दो सेकंड बाद आता है। इसका मतलब setTimeout function ने एक टाइमर सेट किया और बाकी के code को block नहीं किया।"&lt;/p&gt;

&lt;p&gt;इससे हमें ये yah समझ में आता है कि asynchronous code का फायदा यह है कि यह लंबे समय तक चलने वाली operations like api calls को handle कर सकता है bina baaki code part ko block kiye. &lt;/p&gt;

&lt;p&gt;इस asynchronous behavior को manage करने के लिए promises or async/await का use किया जाता है।&lt;/p&gt;

&lt;p&gt;[Screen shows: Synchronous vs Asynchronous code]&lt;/p&gt;

&lt;p&gt;[Scene 2: Promises ?]&lt;/p&gt;

&lt;p&gt;ham aage badne se pahle promise k baare mai jaan lete hai &lt;br&gt;
toh dosto Promise एक ऐसा object है जो asynchronous operations के लिए result provide करता है Ab yah result 3 states mai ho sakte hai 1st state Pending (Initial State) 2nd state Fulfilled (Success) 3rd state Rejected (Failure). &lt;/p&gt;

&lt;p&gt;Ab ham in state k baare mai samjh lete hai&lt;/p&gt;

&lt;p&gt;pending or initial state means jab ham promise create krte hai tab uski initial state pending hoti hai and yah ae show krta hai ki asynchronous operation पूरा नहीं हुआ है &lt;/p&gt;

&lt;p&gt;Fulfilled (Success) means अगर asynchronous operation successfully complete हो गया, तो Promise 'Fulfilled' state में चला जाता है। इस case में एक value या result मिलता है&lt;/p&gt;

&lt;p&gt;Rejected (Failure) means अगर asynchronous operation fail हो गया, तो Promise 'Rejected' state में चला जाता है। इस case में हमें error मिलता है&lt;/p&gt;

&lt;p&gt;How to create promise ?&lt;/p&gt;

&lt;p&gt;ab ham example k sath samjhte hai promise create kaise krte hai&lt;/p&gt;

&lt;p&gt;let promise = new Promise((resolve, reject) =&amp;gt; {&lt;br&gt;
    let success = true;  // इसे try/catch से simulate कर सकते हैं&lt;br&gt;
    if (success) {&lt;br&gt;
        resolve("Operation Successful");&lt;br&gt;
    } else {&lt;br&gt;
        reject("Operation Failed");&lt;br&gt;
    }&lt;br&gt;
});&lt;/p&gt;

&lt;p&gt;promise&lt;br&gt;
    .then((result) =&amp;gt; console.log(result))  // Fulfilled case&lt;br&gt;
    .catch((error) =&amp;gt; console.log(error));  // Rejected case&lt;/p&gt;

&lt;p&gt;इस code में हमने एक Promise बनाया। अगर success true है, तो resolve call होगा और message print होगा: 'Operation Successful'।&lt;br&gt;
लेकिन अगर operation fail हो गया, तो reject call होगा और हमें error मिलेगा: 'Operation Failed'।&lt;/p&gt;

&lt;p&gt;फिर हमने .then और .catch का use करके promise के result को handle किया।&lt;/p&gt;

&lt;p&gt;ab ham aage badne se pahle asynchronous operation hote kya hai un per discuss kr lete hai&lt;/p&gt;

&lt;p&gt;Asynchronous operations वो operations होते हैं जो background में चलती हैं, और main program execution को block किए बिना अपना काम पूरा करती हैं। जब ये operations complete हो जाती हैं, तो हमें result provide करती हैं&lt;/p&gt;

&lt;p&gt;like -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fetch data from an API. (asynchronous operation)&lt;/li&gt;
&lt;li&gt;Process the fetched data.(asynchronous operation)&lt;/li&gt;
&lt;li&gt;Save the processed data.(asynchronous operation)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How to Handle multiple asynchronous operation ?&lt;/p&gt;

&lt;p&gt;Now, imagine you have a sequence of operations where each operation depends on the result of the previous one:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fetch data from an API. (asynchronous operation)&lt;/li&gt;
&lt;li&gt;Process the fetched data.(asynchronous operation)&lt;/li&gt;
&lt;li&gt;Save the processed data.(asynchronous operation)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;yah per har ak asynchronous operation dependent hai doosre asynchronous operation per.&lt;/p&gt;

&lt;p&gt;Ab hamare paas teen tarike hai asynchronous operation ko handle krne k liye aur ham aage janenge kause best tarika hai&lt;/p&gt;

&lt;p&gt;Using Callback&lt;br&gt;
Using Promise&lt;br&gt;
Using async/await&lt;/p&gt;

&lt;p&gt;ab ham aage badne se pahle callback kya hota hai samjh lete hai &lt;br&gt;
dosto -&lt;br&gt;
callback ek aise function ko kehte hain jo kisi doosre function ko argument ke form mein diya jaata hai, aur jab zarurat padti hai tab wo function usse call karta hai&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 doSomething(callback: () =&amp;gt; void) {
  console.log("Doing something...");
  callback(); // Call the callback
}

function onDone() {
  console.log("Done!");
}

// Use the function with a callback
doSomething(onDone);

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

&lt;/div&gt;



&lt;p&gt;Iska matlab hai ki ek function ke andar doosra function "wapas bulane" (call back karne) ke liye diya jaata hai. Callback ka use zyada tar asynchronous operations (jaise ki data fetch karna, file read karna, etc.) ke liye kiya jaata hai.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetchData(data1, (result1) =&amp;gt; {
  processData(result1, (result2) =&amp;gt; {
    saveData(result2, (result3) =&amp;gt; {
      console.log(result3);
    });
  });
});

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

&lt;/div&gt;



&lt;p&gt;aap screen per code dekh sakte hai yah per teen asynchronous operation ho rahe hai -&lt;br&gt;
fetch data()&lt;br&gt;
processData()&lt;br&gt;
savedData()&lt;/p&gt;

&lt;p&gt;aur yah teeno operation ak doosre per dependent hai means jab ham fetch karenge data api se uske baad he ham usko process kar sakte hai and process krne ke baad he ham usko save kr sakt hai.&lt;/p&gt;

&lt;p&gt;lkin dosto jab aap is code k structure ko dekhte hai to yah ak complex structure hai like a tree and isi structure ko ham call back hell kehte hai जहां readability और maintainability काफी मुश्किल हो जाती है&lt;/p&gt;

&lt;p&gt;ab dosto iss code ko promise chains mai convert krte hai to aap dekh sakte hai code screen per&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetchData()
  .then(result1 =&amp;gt; processData(result1))
  .then(result2 =&amp;gt; saveData(result2))
  .then(result3 =&amp;gt; {
    console.log(result3);
  })
  .catch(error =&amp;gt; {
    console.error(error);
  });

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

&lt;/div&gt;



&lt;p&gt;ydi aap iss code ko callback hell code se compare krenge to aap observe krenge ki yah per ham then function ka use kr rhe hai jo code ki readability improve kr rha hai compared to callback but not fully and also error handling abhee bhee muskil hai handle krna. &lt;/p&gt;

&lt;p&gt;to chaliye ab ham jante hai 100% code radability and mainainabilty and proper error handling kaise achieve kr sakte hai -&lt;/p&gt;

&lt;p&gt;[Scene 3: What is async/await?]&lt;br&gt;
Host:&lt;br&gt;
"अब आते हैं async/await पर। async/await JavaScript और TypeScript का syntax है, जो asynchronous code को synchronous जैसे दिखाता है। यह Promise-based operations को ज्यादा readable और clean बना देता है।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Simple async/await example]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"आप देख सकते हैं, async function में हम await का use करते हैं जिससे code sequentially execute होता है जैसे कि हम synchronous code लिख रहे हों।"&lt;/p&gt;

&lt;p&gt;[Scene 4: The async Keyword]&lt;br&gt;
Host:&lt;br&gt;
"चलिये अब बात करते हैं async keyword के बारे में। जब हम किसी function के सामने async लगाते हैं, तो वो function automatically एक Promise return करता है। इसका मतलब अगर आप कोई value return करेंगे, तो वो value Promise के अंदर encapsulate हो जाएगी।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Async function example]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"आप देख सकते हैं, यहां एक async function है, जो एक Promise return कर रहा है, भले ही हमने explicitly Promise नहीं लिखा।"&lt;/p&gt;

&lt;p&gt;[Scene 5: The await Keyword]&lt;br&gt;
Host:&lt;br&gt;
"अब await keyword की बात करते हैं। await का use हम तब करते हैं जब हम चाहते हैं कि हमारा code एक asynchronous operation के result का इंतजार करे।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Await example with setTimeout]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"आप देख सकते हैं, await किसी Promise के resolve होने तक code को pause कर देता है, और जैसे ही result मिलता है, execution आगे बढ़ता है।"&lt;/p&gt;

&lt;p&gt;[Scene 6: Error Handling with async/await]&lt;br&gt;
Host:&lt;br&gt;
"अच्छा, अब बात करते हैं error handling की। जब हम asynchronous operations करते हैं, तो हमें errors handle करने के लिए proper strategies adopt करनी पड़ती हैं।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Try/catch with async/await example]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"यहां try/catch block का use करके हम errors को easily handle कर सकते हैं। अगर कोई error आए, तो catch block उसे पकड़ लेता है।"&lt;/p&gt;

&lt;p&gt;[Scene 7: Chaining async/await]&lt;br&gt;
Host:&lt;br&gt;
"अब बात करते हैं chaining की। अगर हमें multiple async operations को execute करना हो, तो हम उन्हें await के साथ चेन कर सकते हैं।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Multiple async/await functions]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"यहां हमने तीन async functions को sequentially execute किया है, जिससे हम एक के बाद एक operations handle कर सकते हैं।"&lt;/p&gt;

&lt;p&gt;[Scene 8: Returning Values from async Functions]&lt;br&gt;
Host:&lt;br&gt;
"जब हम async function से कोई value return करते हैं, तो वो value एक Promise के अंदर wrapped होती है।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Return value from async function]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"अगर हम किसी async function से कोई string return करते हैं, तो वो Promise string return करता है। इसका मतलब आपको हमेशा .then() या await के साथ उस result को access करना होगा।"&lt;/p&gt;

&lt;p&gt;[Scene 9: Parallel Execution with async/await]&lt;br&gt;
Host:&lt;br&gt;
"कभी-कभी हमें multiple asynchronous tasks parallelly execute करने होते हैं। इसके लिए हम Promise.all() का use करते हैं।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Example using Promise.all]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"यहां हम तीन अलग-अलग API calls को parallelly execute कर रहे हैं, ताकि वे एक साथ execute हो सकें और time saving हो सके।"&lt;/p&gt;

&lt;p&gt;[Scene 10: Working with TypeScript Types]**&lt;br&gt;
Host:&lt;br&gt;
"अब बात करते हैं TypeScript में async/await को type safe बनाने की। TypeScript में हम async functions के return types को type करके उन्हें ज्यादा readable और maintainable बना सकते हैं।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Typing async function example]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"यहां हम return type को Promise के रूप में define कर रहे हैं, जिससे कि हमें पता चले कि async function number type का value return करेगा।"&lt;/p&gt;

&lt;p&gt;[Scene 11: Common Mistakes with async/await]&lt;br&gt;
Host:&lt;br&gt;
"अब हम कुछ common mistakes के बारे में बात करते हैं। सबसे बड़ी गलती होती है await का use न करना।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Mistake example: forgot to await]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"यहां हमने await का use नहीं किया, और result सही से return नहीं हो रहा। हमेशा await का use करें जब आपको asynchronous operations का result चाहिए।"&lt;/p&gt;

&lt;p&gt;[Scene 12: Real-world Use Cases]&lt;br&gt;
Host:&lt;br&gt;
"अब हम कुछ real-world examples देखेंगे। मान लीजिए हमें किसी API से डेटा fetch करना है।"&lt;/p&gt;

&lt;p&gt;[Screen shows: API fetch example with async/await]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"यहां हम एक API से data fetch कर रहे हैं और उसे render करने के लिए async/await का use कर रहे हैं।"&lt;/p&gt;

&lt;p&gt;[Scene 13: Async Iterators and for await...of]&lt;br&gt;
Host:&lt;br&gt;
"अगर हमें एक asynchronous iterable के ऊपर iterate करना हो, तो हम for await...of loop का use कर सकते हैं।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Async iterators example]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"यहां हम for await...of का use करके एक asynchronous collection को loop कर रहे हैं।"&lt;/p&gt;

&lt;p&gt;[Scene 14: Unit Testing with async/await]&lt;br&gt;
Host:&lt;br&gt;
"अगर हम async functions का unit test करना चाहते हैं, तो Jasmine या Jest जैसी testing libraries में async/await का use कर सकते हैं।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Testing async function in Jasmine]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"यहां हम async function को test कर रहे हैं, और await का use करके हम expected result compare कर रहे हैं।"&lt;/p&gt;

&lt;p&gt;[Scene 15: Conclusion and Best Practices]&lt;br&gt;
Host:&lt;br&gt;
"तो दोस्तों, इस वीडियो में हमने async/await के बारे में बहुत कुछ सीखा। हमने देखा कि कैसे async/await asynchronous code को synchronous जैसा बना देता है, और इसे readable और maintainable बनाता है।"&lt;/p&gt;

&lt;p&gt;[Screen shows: Key takeaways]&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"सबसे important बात यह है कि हमें हमेशा await का सही use करना चाहिए, और error handling के लिए try/catch blocks का use करना चाहिए।"&lt;/p&gt;

&lt;p&gt;Host:&lt;br&gt;
"अगर आपको ये वीडियो पसंद आया हो, तो please like करें, subscribe करें और bell icon दबाएं ताकि आपको हमारी नई videos की notifications मिलती रहें। धन्यवाद!"&lt;/p&gt;

&lt;p&gt;[Closing Scene]&lt;br&gt;
[Background Music fades out]&lt;/p&gt;

</description>
    </item>
    <item>
      <title>hindi angular script</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Sat, 09 Nov 2024 06:54:58 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/hindi-angular-script-b8f</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/hindi-angular-script-b8f</guid>
      <description>&lt;p&gt;Start --------&amp;gt;&lt;/p&gt;

&lt;p&gt;Hi friends welcome back to target developers आज का टॉपिक है -&lt;/p&gt;

&lt;p&gt;Why Async Await in javascript/typescript ?&lt;/p&gt;

&lt;p&gt;toh aaj ke video mai cover krenge -&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;synchronous and asynchronous mai difference आखिर है क्या ?&lt;/li&gt;
&lt;li&gt;Promise आखिर है क्या ?&lt;/li&gt;
&lt;li&gt;Async Await की एंट्री ?&lt;/li&gt;
&lt;li&gt;understand with code ?&lt;/li&gt;
&lt;li&gt;error handling ?&lt;/li&gt;
&lt;li&gt;Understand with story ?&lt;/li&gt;
&lt;li&gt;Real world application ?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;वीडियो को आखिर तक देखिएगा, क्योंकि last में मैं एक ऐसा example दूंगा जिससे aapka &lt;/p&gt;

&lt;p&gt;sara confusion दूर हो jayga। &lt;/p&gt;

&lt;p&gt;Toh chaliye shuru krte hai&lt;/p&gt;

&lt;p&gt;भाग 1: synchronous और asynchronous का difference &lt;/p&gt;

&lt;p&gt;सबसे पहले समझते हैं सिंक्रोनस और असिंक्रोनस का मतलब ?&lt;/p&gt;

&lt;p&gt;suppose kriye, आपने अपने friend को कॉल किया और जब तक वो कॉल पिक नहीं करता, आप बस फोन पर इंतजार करते रहते हैं। ये हुआ synchronous तरीका। &lt;/p&gt;

&lt;p&gt;scenario 2&lt;br&gt;
अब, अगर आप अपने friend को कॉल करते हैं और जवाब आने तक दूसरे काम करने लगते हैं, ये है asynchronous तरीका।&lt;/p&gt;

&lt;p&gt;प्रोग्रामिंग में भी ऐसा ही होता है। &lt;/p&gt;

&lt;p&gt;synchronous में, कोड एक के बाद एक चलता है। लेकिन अगर कोई काम ज्यादा समय ले रहा है, तो पूरा प्रोग्राम वहीं रुक जाता है। &lt;/p&gt;

&lt;p&gt;वहीं, asynchronous में प्रोग्राम आगे बढ़ता रहता है, बिना रुके। &lt;/p&gt;

&lt;p&gt;यही कारण है कि Async Await इतना जरूरी है।&lt;/p&gt;

&lt;p&gt;भाग 2: प्रॉमिस (Promise) क्या है?&lt;/p&gt;

&lt;p&gt;अब सवाल आता है कि Async Await कैसे काम करता है?&lt;/p&gt;

&lt;p&gt;इसके लिए हमें पहले समझना होगा Promise ?&lt;/p&gt;

&lt;p&gt;Promise एक वादा है। &lt;/p&gt;

&lt;p&gt;जैसे मान लीजिए, आप friend से कहते हैं कि वो शाम को पिज्जा लेकर आएगा। &lt;/p&gt;

&lt;p&gt;अब friend तीन चीजें कर सकता है:&lt;/p&gt;

&lt;p&gt;friend पिज्जा लेकर आएगा - Promise Resolved।&lt;/p&gt;

&lt;p&gt;friend कहेगा कि पिज्जा नहीं ला सकता - Promise Rejected।&lt;/p&gt;

&lt;p&gt;or friend अभी कुछ न बोले, आप इंतजार करें - Pending।&lt;/p&gt;

&lt;p&gt;Promise का यही रोल होता है कोड में। ये बताता है कि कोई काम होगा, और उसके बाद हमें एक result मिलेगा।&lt;/p&gt;

&lt;p&gt;भाग 3: Async Await की entry&lt;/p&gt;

&lt;p&gt;अब आता है असली hero, Async Await।&lt;/p&gt;

&lt;p&gt;अगर प्रॉमिस वादा करता है, तो Await उस वादे का result आने तक इंतजार करता है,&lt;/p&gt;

&lt;p&gt;और Async ये Ensure  करता है कि प्रोग्राम रुके नहीं। इसका मतलब, आप इंतजार भी करेंगे और दूसरे काम भी बिना किसी रुकावट के चलते रहेंगे।&lt;/p&gt;

&lt;p&gt;भाग 4: code example से समझते हैं&lt;/p&gt;

&lt;p&gt;चलो, इसे एक code example से समझते हैं।&lt;/p&gt;

&lt;p&gt;suppose kriye ki हमें एक सर्वर से डेटा लाना है।&lt;/p&gt;

&lt;p&gt;aap code dekh sakte hai ki humne ynha per ak getdata function&lt;br&gt;
banaya and uske ander fetchdatafromserver function call kiya hai&lt;br&gt;
and fetchdatafromserver function ka kaam hai api call krna.&lt;br&gt;
And hum final result data variable mai hold kr rhe hai. &lt;/p&gt;

&lt;p&gt;Phir next line mai data ko console kra rhe hai.&lt;/p&gt;

&lt;p&gt;function getData() {&lt;br&gt;
  let data = fetchDataFromServer();&lt;br&gt;
  console.log(data); //object promise object&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;to dosto yah ak synchronous code hai kyuki yaha fetchDataFromServer function ko synchronous तरीके से कॉल किया गया है means without await.&lt;/p&gt;

&lt;p&gt;यदि fetchDataFromServer एक प्रॉमिस रिटर्न करता है  तो यह Promise का ऑब्जेक्ट लौटाएगा, न कि actual डेटा ।&lt;/p&gt;

&lt;p&gt;app jab console.log krenge to aapko Promise का ऑब्जेक्ट print hoga.&lt;/p&gt;

&lt;p&gt;ydi fetchDataFromServer function server se data lane mai slow hai&lt;br&gt;
to apka poora code code crash hojayga or stop hojayga.&lt;/p&gt;

&lt;p&gt;लेकिन अगर हम इसे Async Await के साथ लिखें -&lt;/p&gt;

&lt;p&gt;async function getData() {&lt;br&gt;
  let data = await fetchDataFromServer();&lt;br&gt;
  console.log(data); // print actual data from api&lt;br&gt;
}&lt;br&gt;
to dosto yah ak asynchronous code hai kyuki yaha fetchDataFromServer function ko asynchronous तरीके से कॉल किया गया है means with await.&lt;/p&gt;

&lt;p&gt;async function को यह बताता है कि यह एक asynchronous process को संभाल सकता है और promise return krega&lt;/p&gt;

&lt;p&gt;await तब तक function को pause कर देता है जब तक fetchDataFromServer() का प्रॉमिस resolve नहीं हो जाता means jab tk actual data nhi mil jata लेकिन प्रोग्राम का बाकी part बिना रुके चलता रहेगा।&lt;/p&gt;

&lt;p&gt;इसका मतलब यह है कि data में सीधे actual data स्टोर होगा, और फिर &lt;br&gt;
console.log(data); सही डेटा प्रिंट करेगा।&lt;/p&gt;

&lt;p&gt;भाग 5: Error Handling भी जरूरी है&lt;/p&gt;

&lt;p&gt;Async Await के साथ एक खास बात ये है कि आप try-catch ब्लॉक का इस्तेमाल करके error को आसानी से हैंडल कर सकते हैं।&lt;/p&gt;

&lt;p&gt;async function getData() {&lt;br&gt;
  try {&lt;br&gt;
    let data = await fetchDataFromServer();&lt;br&gt;
    console.log(data);&lt;br&gt;
  } catch (error) {&lt;br&gt;
    console.error("कुछ गलती हो गई:", error);&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;भाग 6: कहानी से समझते हैं&lt;/p&gt;

&lt;p&gt;अब इसे एक आसान कहानी से समझते हैं।&lt;br&gt;
मान लीजिए, आप एक रेस्टोरेंट में गए। आपने पिज्जा ऑर्डर किया।&lt;/p&gt;

&lt;p&gt;वेटर ने आपका ऑर्डर लिया (Function Call)।&lt;br&gt;
पिज्जा बनने लगा (Promise)।&lt;br&gt;
अब आप खाना आने का इंतजार कर रहे हैं (Await)।&lt;br&gt;
आखिरकार वेटर पिज्जा लेकर आता है (Promise Resolved)।&lt;br&gt;
अगर पिज्जा नहीं बना, तो वेटर मना कर देता है (Promise Rejected)।&lt;br&gt;
Async Await प्रोग्रामिंग में ठीक ऐसा ही करता है। ये हमें इस इंतजार को मैनेज करने में मदद करता है।&lt;/p&gt;

&lt;p&gt;भाग 7: रियल वर्ल्ड एप्लिकेशन&lt;/p&gt;

&lt;p&gt;दोस्तों, Async Await का सबसे बड़ा फायदा तब होता है जब आप API से डेटा फेच कर रहे हों, फाइल्स read kr rhe हों या डेटाबेस से कुछ access कर रहे हों। इससे आपका कोड क्लीन और आसान हो जाता है।&lt;/p&gt;

&lt;p&gt;भाग 8: अंत में&lt;/p&gt;

&lt;p&gt;तो दोस्तों, Async Await का ये सफर यहीं खत्म होता है। उम्मीद है, अब ये टॉपिक आपको आसान लग रहा होगा। अगले वीडियो में हम Promises और Callbacks की तुलना करेंगे।&lt;/p&gt;

&lt;p&gt;वीडियो अच्छा लगा हो तो लाइक कीजिए, अपने दोस्तों के साथ शेयर कीजिए और चैनल को सब्सक्राइब करना मत भूलिए।&lt;/p&gt;

&lt;p&gt;मिलते हैं अगले वीडियो में, तब तक के लिए कोडिंग करते रहिए और सीखते रहिए। धन्यवाद!&lt;/p&gt;

&lt;p&gt;===============================&lt;/p&gt;

&lt;p&gt;तो दोस्तों, ये थीं 10 आम गलतियां जो TypeScript में async/await इस्तेमाल करते वक्त लोग करते हैं। अगर आप भी इनमें से कोई गलती कर रहे थे, तो अब आप सीख गए हैं। वीडियो को लाइक और चैनल को सब्सक्राइब करना न भूलें। मिलते हैं अगले वीडियो में। धन्यवाद!&lt;/p&gt;

&lt;p&gt;==========================================================================&lt;/p&gt;

&lt;p&gt;स्क्रिप्ट: 10 आम गलतियां जो TypeScript में async/await इस्तेमाल करते वक्त लोग करते हैं&lt;/p&gt;

&lt;p&gt;इंट्रो (0:00 - 1:00):&lt;br&gt;
नमस्ते दोस्तों!&lt;br&gt;
क्या आप TypeScript में async/await का सही इस्तेमाल करना चाहते हैं? लेकिन क्या आप जानते हैं, कई लोग इसमें छोटी-छोटी गलतियां करते हैं, जो उनके कोड को स्लो और गलत बना देती हैं? आज के इस वीडियो में, हम जानेंगे 10 ऐसी आम गलतियां जो आप भी शायद कर रहे होंगे।&lt;br&gt;
तो वीडियो को आखिर तक जरूर देखिए, क्योंकि अंत में मैं एक बोनस टिप भी देने वाला हूं जो आपकी कोडिंग स्किल्स को लेवल-अप कर देगी।&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;केवल async लिखना और await भूल जाना (1:00 - 3:00)
सबसे पहली और बड़ी गलती जो लोग करते हैं, वो है async फ़ंक्शन तो लिख लेते हैं लेकिन अंदर await इस्तेमाल करना भूल जाते हैं।
मान लीजिए, आपने एक API कॉल बनाई:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy code&lt;br&gt;
async function fetchData() {&lt;br&gt;&lt;br&gt;
   fetch('&lt;a href="https://api.example.com/data'" rel="noopener noreferrer"&gt;https://api.example.com/data'&lt;/a&gt;);&lt;br&gt;&lt;br&gt;
}&lt;br&gt;
अब आपको क्या लगता है, ये सही है? गलत!&lt;br&gt;
क्योंकि आपने fetch के रिजल्ट को वेट नहीं किया। इससे आपका कोड बिना डेटा के आगे बढ़ जाएगा। सही तरीका है:&lt;/p&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy code&lt;br&gt;
async function fetchData() {&lt;br&gt;&lt;br&gt;
   const response = await fetch('&lt;a href="https://api.example.com/data'" rel="noopener noreferrer"&gt;https://api.example.com/data'&lt;/a&gt;);&lt;br&gt;&lt;br&gt;
}&lt;br&gt;
देखा? await लगाने से अब ये सही काम करेगा।&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Error handling करना भूल जाना (3:00 - 5:00)
आपने देखा होगा, कई बार लोग ट्राय-कैच (try-catch) ब्लॉक का इस्तेमाल नहीं करते।
अगर आपकी API कॉल फेल हो गई तो क्या होगा? प्रोग्राम क्रैश कर जाएगा। सही तरीका है:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy code&lt;br&gt;
async function fetchData() {&lt;br&gt;&lt;br&gt;
   try {&lt;br&gt;&lt;br&gt;
      const response = await fetch('&lt;a href="https://api.example.com/data'" rel="noopener noreferrer"&gt;https://api.example.com/data'&lt;/a&gt;);&lt;br&gt;&lt;br&gt;
   } catch (error) {&lt;br&gt;&lt;br&gt;
      console.error('Error:', error);&lt;br&gt;&lt;br&gt;
   }&lt;br&gt;&lt;br&gt;
}&lt;br&gt;
अब अगर एरर आएगी, तो आपका कोड संभल जाएगा।&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;एक साथ कई async ऑपरेशंस को await करना (5:00 - 7:00)
अब सोचिए, अगर आपके पास तीन API कॉल्स हैं, और आप हर कॉल को अलग-अलग await करते हैं:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy code&lt;br&gt;
const data1 = await fetch('url1');&lt;br&gt;&lt;br&gt;
const data2 = await fetch('url2');&lt;br&gt;&lt;br&gt;
const data3 = await fetch('url3');&lt;br&gt;
ये काफी टाइम लेगा। लेकिन हम इसे साथ में भी चला सकते हैं:&lt;/p&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy code&lt;br&gt;
const [data1, data2, data3] = await Promise.all([&lt;br&gt;&lt;br&gt;
   fetch('url1'),&lt;br&gt;&lt;br&gt;
   fetch('url2'),&lt;br&gt;&lt;br&gt;
   fetch('url3')&lt;br&gt;&lt;br&gt;
]);&lt;br&gt;
देखा? एक साथ सारे कॉल्स फटाफट हो गए।&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Async फ़ंक्शन में return करना भूल जाना (7:00 - 9:00)
लोग अक्सर async फ़ंक्शन में कुछ रिटर्न करना भूल जाते हैं।
अगर आपने लिखा:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy code&lt;br&gt;
async function getData() {&lt;br&gt;&lt;br&gt;
   await fetch('url');&lt;br&gt;&lt;br&gt;
}&lt;br&gt;
तो ये कुछ भी रिटर्न नहीं करेगा। सही तरीका है:&lt;/p&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy code&lt;br&gt;
async function getData() {&lt;br&gt;&lt;br&gt;
   const response = await fetch('url');&lt;br&gt;&lt;br&gt;
   return response.json();&lt;br&gt;&lt;br&gt;
}&lt;br&gt;
अब जब ये फंक्शन कॉल होगा, ये डेटा रिटर्न करेगा।&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Nested async/await लिखना (9:00 - 11:00)
कई बार लोग async/await को नेस्टेड बना देते हैं, जिससे कोड बहुत गन्दा हो जाता है।&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy code&lt;br&gt;
async function main() {&lt;br&gt;&lt;br&gt;
   const result = await someFunction(async () =&amp;gt; {&lt;br&gt;&lt;br&gt;
      return await anotherFunction();&lt;br&gt;&lt;br&gt;
   });&lt;br&gt;&lt;br&gt;
}&lt;br&gt;
इसे सिंपल बनाइए:&lt;/p&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy code&lt;br&gt;
async function main() {&lt;br&gt;&lt;br&gt;
   const result = await anotherFunction();&lt;br&gt;&lt;br&gt;
}&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;बड़ी फाइल्स में async/await का गलत इस्तेमाल (11:00 - 13:00)&lt;br&gt;
कभी-कभी async/await के साथ लंबे-लंबे फंक्शंस लिखे जाते हैं, जो समझना मुश्किल हो जाता है। हमेशा छोटे-छोटे फंक्शंस बनाएं। इससे कोड पढ़ने और डिबग करने में आसानी होगी।&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unhandled Rejections (13:00 - 15:00)&lt;br&gt;
अगर आप किसी भी async फ़ंक्शन के रेजेक्शन को हैंडल नहीं करते, तो यह एक बहुत बड़ी गलती है। इसे हमेशा संभालिए।&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;async/await और .then() को मिक्स करना (15:00 - 17:00)&lt;br&gt;
कभी-कभी लोग async/await के साथ .then() का इस्तेमाल करते हैं।&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;typescript&lt;br&gt;
Copy code&lt;br&gt;
async function getData() {&lt;br&gt;&lt;br&gt;
   const response = await fetch('url').then(res =&amp;gt; res.json());&lt;br&gt;&lt;br&gt;
}&lt;br&gt;
ये सही तरीका नहीं है। केवल await का इस्तेमाल करें।&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Async Loops में await का गलत इस्तेमाल (17:00 - 18:30)&lt;br&gt;
फॉर-लूप में await गलत तरीके से लगाने पर परफॉर्मेंस स्लो हो जाती है। सही तरीका है Promise.all() का इस्तेमाल।&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;सही Testing न करना (18:30 - 19:30)&lt;br&gt;
लोग async/await को टेस्ट करना भूल जाते हैं। हमेशा यूनिट टेस्टिंग करें ताकि आपका कोड सही से काम करे।&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;बोनस टिप (19:30 - 20:00):&lt;br&gt;
जब भी async/await का इस्तेमाल करें, अपनी कोडिंग को सिंपल और क्लीन रखें। इससे आपका काम आसान होगा।&lt;/p&gt;

&lt;p&gt;आउट्रो (20:00):&lt;br&gt;
तो दोस्तों, ये थीं 10 आम गलतियां जो TypeScript में async/await का इस्तेमाल करते वक्त लोग करते हैं। अगर आप इनसे बचेंगे, तो आपका कोड तेज और बेहतर काम करेगा।&lt;br&gt;
अगर आपको वीडियो पसंद आया हो, तो लाइक करें, चैनल को सब्सक्राइब करें, और कमेंट करके बताएं कि आप अगला वीडियो किस टॉपिक पर देखना चाहते हैं।&lt;br&gt;
धन्यवाद, मिलते हैं अगले वीडियो में!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>quiz topics and questions</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Tue, 01 Oct 2024 05:30:15 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/quiz-topics-and-questions-4hem</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/quiz-topics-and-questions-4hem</guid>
      <description>&lt;ol&gt;
&lt;li&gt;rxjs&lt;/li&gt;
&lt;li&gt;component&lt;/li&gt;
&lt;li&gt;services&lt;/li&gt;
&lt;li&gt;subject behavior&lt;/li&gt;
&lt;li&gt;pipes&lt;/li&gt;
&lt;li&gt;angular life cycle&lt;/li&gt;
&lt;li&gt;decorators&lt;/li&gt;
&lt;li&gt;directives&lt;/li&gt;
&lt;li&gt;string interpolation&lt;/li&gt;
&lt;li&gt;string handling&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>yt enhance quality</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Fri, 13 Sep 2024 06:50:50 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/yt-enhance-quality-4dng</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/yt-enhance-quality-4dng</guid>
      <description>&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=N6-Q2dgodLs&amp;amp;t=247s" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=N6-Q2dgodLs&amp;amp;t=247s&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;shorts -- &lt;a href="https://www.youtube.com/watch?v=7IWIQJKdCGU" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=7IWIQJKdCGU&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=oAoYFZvMQEs" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=oAoYFZvMQEs&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Angular Interview Questions</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Mon, 02 Sep 2024 13:20:20 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/angular-interview-questions-b1o</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/angular-interview-questions-b1o</guid>
      <description>&lt;p&gt;&lt;a href="https://chatgpt.com/share/756c7605-3df3-487d-a709-7bc603664d85" rel="noopener noreferrer"&gt;https://chatgpt.com/share/756c7605-3df3-487d-a709-7bc603664d85&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chatgpt.com/share/bef89b0a-3d31-4d8a-aff4-7b3e8c18e9c0" rel="noopener noreferrer"&gt;https://chatgpt.com/share/bef89b0a-3d31-4d8a-aff4-7b3e8c18e9c0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chatgpt.com/share/4acf8d94-bf02-4a9b-afc5-dc52a0344eba" rel="noopener noreferrer"&gt;https://chatgpt.com/share/4acf8d94-bf02-4a9b-afc5-dc52a0344eba&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=Coyy79wRz_s" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=Coyy79wRz_s&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=PoRJizFvM7s" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=PoRJizFvM7s&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chatgpt.com/share/756c7605-3df3-487d-a709-7bc603664d85" rel="noopener noreferrer"&gt;https://chatgpt.com/share/756c7605-3df3-487d-a709-7bc603664d85&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;synchronous/asynchronous/callbacks/promises/async await&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;synchronous - &lt;br&gt;
execute line by line consecutively in a sequential manner. Code that waits for an operation to complete.&lt;/p&gt;

&lt;p&gt;asynchronous - &lt;br&gt;
execute multiple line or operation concurrently without waiting. Doesnt block the code execution flow and allow the program to continue i/o operation,fetching data etc.. &lt;/p&gt;

&lt;p&gt;Handled By - Callbacks, Promises,Async Await&lt;/p&gt;

&lt;p&gt;Callbacks - &lt;br&gt;
Promises - &lt;br&gt;
Async Await - &lt;/p&gt;

</description>
    </item>
    <item>
      <title>My Projects</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Wed, 07 Aug 2024 04:34:32 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/my-projects-4e9f</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/my-projects-4e9f</guid>
      <description>&lt;p&gt;&lt;strong&gt;Project Name:&lt;/strong&gt; real-estate-management&lt;/p&gt;

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

&lt;p&gt;A online property management solution for real estate. It is a cross-platform mobile application designed to connect property owners and Buyers. Also property owners can rent their vacant spaces. &lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Login/Sign up&lt;/li&gt;
&lt;li&gt;Home page see all available properties&lt;/li&gt;
&lt;li&gt;Search properties&lt;/li&gt;
&lt;li&gt;Add properties page&lt;/li&gt;
&lt;li&gt;properties detail page&lt;/li&gt;
&lt;li&gt;About us page&lt;/li&gt;
&lt;li&gt;Auto Redirect using Guards.&lt;/li&gt;
&lt;li&gt;Profile Managment&lt;/li&gt;
&lt;li&gt;Image uploaded functionality&lt;/li&gt;
&lt;li&gt;Image delete functionality&lt;/li&gt;
&lt;li&gt;Categories – Create, Update and Delete,Image Uploaded functionality&lt;/li&gt;
&lt;li&gt;properties – Create, Update and Delete,Image Uploaded functionality&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Technologies Used:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ionic 8+&lt;/li&gt;
&lt;li&gt;Angular 17&lt;/li&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;li&gt;CSS&lt;/li&gt;
&lt;li&gt;BOOTSTRAP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Challenges &amp;amp; Solutions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When dealing with large lists or complex data sets, the app might experience performance degradation, such as slow scrolling or high memory usage, which can lead to a poor user experience.&lt;/p&gt;

&lt;p&gt;Ionic provides a ion-virtual-scroll component that only renders the items currently visible on the screen, thus improving performance by reducing the number of DOM elements.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>IONIC AND ANGULAR</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Tue, 06 Aug 2024 13:35:51 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/ionic-and-angular-1mph</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/ionic-and-angular-1mph</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Ionic?&lt;/strong&gt;&lt;br&gt;
Ionic is a popular &lt;em&gt;open-source framework&lt;/em&gt; for building cross-platform mobile applications using &lt;em&gt;web technologies&lt;/em&gt; such as HTML, CSS, and JavaScript. It allows developers to create native-like apps for iOS, Android, and the web &lt;em&gt;from a single codebase.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between Ionic and Cordova?&lt;/strong&gt;&lt;br&gt;
Ionic focuses on the app's look and feel, Cordova handles the interaction with native device functionalities like the camera or GPS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are Ionic components and how are they used?&lt;/strong&gt;&lt;br&gt;
Ionic components are pre-designed UI elements that follow platform-specific design guidelines, like Material Design for Android and Human Interface Guidelines for iOS. They include elements like buttons, cards, and lists, which help create a consistent and visually appealing user interface.&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;ion-button&amp;gt;Click Me&amp;lt;/ion-button&amp;gt;
 &amp;lt;ion-card&amp;gt;
   &amp;lt;ion-card-header&amp;gt;
     &amp;lt;ion-card-title&amp;gt;Card Title&amp;lt;/ion-card-title&amp;gt;
   &amp;lt;/ion-card-header&amp;gt;
   &amp;lt;ion-card-content&amp;gt;Card Content&amp;lt;/ion-card-content&amp;gt;
&amp;lt;/ion-card&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How does Ionic handle navigation?&lt;/strong&gt;&lt;br&gt;
Ionic handles navigation using the Angular Router (for Angular projects) or the appropriate routing library for React and Vue. It uses the  component as a placeholder for dynamically rendered views based on the application's route configuration. This allows for efficient and seamless navigation between different pages or views within the app.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Capacitor and how does it relate to Ionic?&lt;/strong&gt;&lt;br&gt;
Capacitor is a native runtime developed by the Ionic team that allows you to build cross-platform mobile applications with web technologies. It provides native APIs and plugins for accessing device features and integrates seamlessly with Ionic for modern development experiences. While Ionic focuses on the UI and app structure, Capacitor handles native functionality and deployment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you handle platform-specific functionality in an Ionic app?&lt;/strong&gt;&lt;br&gt;
You can handle platform-specific functionality in an Ionic app by using the Platform service to detect the platform and execute platform-specific code. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Platform } from '@ionic/angular';

constructor(private platform: Platform) {
  if (this.platform.is('ios')) {
    // iOS-specific code
  } else if (this.platform.is('android')) {
    // Android-specific code
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What is Ionic’s CLI and what are some common commands?&lt;/strong&gt;&lt;br&gt;
ionic start [app-name]: Creates a new Ionic project.&lt;br&gt;
ionic serve: Runs the app in a local development server.&lt;br&gt;
ionic build: Builds the app for production.&lt;br&gt;
ionic cap add [platform]: Adds a native platform like iOS or Android.&lt;br&gt;
ionic cap sync: Syncs the latest code with the native platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the purpose of the @ionic-native package?&lt;/strong&gt;&lt;br&gt;
The @ionic-native package provides Angular wrappers for Cordova and Capacitor plugins, making it easier to use native device features in Ionic applications by offering a straightforward, type-safe API.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Scenario: You have a requirement to implement a feature that needs to access the device's camera. How would you handle this in Ionic?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To access the device's camera in Ionic, you would use the &lt;em&gt;Capacitor Camera plugin&lt;/em&gt;. First, ensure that the @capacitor/camera plugin is installed in your project&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario: You need to ensure that your Ionic app performs well on older devices. What strategies would you use?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Implement &lt;em&gt;lazy loading&lt;/em&gt; for images and modules to decrease initial load time and improve performance.&lt;br&gt;
Use efficient &lt;em&gt;Angular change detection strategies&lt;/em&gt; and avoid excessive DOM manipulations.&lt;br&gt;
&lt;em&gt;Reduce the initial bundle size&lt;/em&gt; of Application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario: Your app needs to handle offline data synchronization. How would you implement this in Ionic?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use &lt;em&gt;Capacitor Storage API&lt;/em&gt;  to store data &lt;em&gt;locally&lt;/em&gt; when the app is offline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario: You need to implement custom theming in your Ionic app. How would you approach this?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Define custom CSS&lt;/em&gt; variables in your src/theme/variables.scss file to override default Ionic styles.&lt;br&gt;
&lt;em&gt;Utilize SCSS&lt;/em&gt; to create custom themes and dynamically change themes if needed.&lt;br&gt;
&lt;em&gt;Implement a theme service&lt;/em&gt; that changes the active theme by updating CSS variables at runtime.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scenario: Your Ionic app needs to handle user authentication with social login providers. What would be your approach?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Integrate with authentication libraries&lt;/em&gt; like Auth0, Firebase Authentication, or OAuth providers that support social logins.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>ss</title>
      <dc:creator>Shivam Sahu</dc:creator>
      <pubDate>Tue, 25 Jun 2024 13:21:06 +0000</pubDate>
      <link>https://dev.to/shivam_sahu_704d021337aec/ss-o51</link>
      <guid>https://dev.to/shivam_sahu_704d021337aec/ss-o51</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function printDuplicateCharacters(str) {
    // Step 1: Initialize an empty object to store character counts
    let charCount = {};

    // Step 2: Iterate through the string to count each character
    for (let i = 0; i &amp;lt; str.length; i++) {
        let char = str[i];
        if (charCount[char]) {
            charCount[char]++;
        } else {
            charCount[char] = 1;
        }
    }

    // Step 3: Find and print characters with a count greater than one
    for (let char in charCount) {
        if (charCount[char] &amp;gt; 1) {
            console.log(char + ": " + charCount[char]);
        }
    }
}

// Example usage
let inputString = "programming";
printDuplicateCharacters(inputString);

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

&lt;/div&gt;



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