<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Imran Younas on Medium]]></title>
        <description><![CDATA[Stories by Imran Younas on Medium]]></description>
        <link>https://medium.com/@imranyounaskaa123?source=rss-4c82fce2846c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PFPFcTNmk-0YCcV2Vji_qw.jpeg</url>
            <title>Stories by Imran Younas on Medium</title>
            <link>https://medium.com/@imranyounaskaa123?source=rss-4c82fce2846c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 03:19:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@imranyounaskaa123/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[TypeScript Generics: Building Flexible and Reusable Code]]></title>
            <link>https://medium.com/@imranyounaskaa123/typescript-generics-building-flexible-and-reusable-code-2852587a923b?source=rss-4c82fce2846c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2852587a923b</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[generic-functions]]></category>
            <category><![CDATA[reuseable]]></category>
            <category><![CDATA[class]]></category>
            <category><![CDATA[generics]]></category>
            <dc:creator><![CDATA[Imran Younas]]></dc:creator>
            <pubDate>Sun, 22 Sep 2024 07:07:58 GMT</pubDate>
            <atom:updated>2024-09-22T10:20:43.118Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*Y6T9q4hEOF4NVzTVtRakvg.jpeg" /></figure><p>Generics are used to make reusable code by creating components that can work with any data type while still maintaining type safety. We use generics with functions, classes, or interfaces, employing a placeholder that can be replaced based on the type we need. This enables the DRY (Don’t Repeat Yourself) principle.</p><h4>Why Use Generics?</h4><p>The main reasons we use generics are:</p><ul><li>Type Safety: Generics ensure we use the correct data type, reducing runtime errors.</li><li>Reusability: By using generics, we can prevent duplicate code and reuse functions, classes, and interfaces based on type, instead of creating new ones for every type.</li><li>Clarity: Code becomes more understandable and readable, allowing us to check what types of data are expected.</li></ul><h4>Example:</h4><pre>function identity&lt;T&gt;(arg: T): T {<br>    return arg;<br>}</pre><p>In the example above, we use the &lt;T&gt; placeholder, which can be replaced with any type we require when calling the function.</p><h4>What Happens if You Don’t Use Generics?</h4><ul><li>Type Inference: If we use any, we lose type safety, which can lead to runtime errors when the wrong type is used.</li><li>Code Duplication: Without generics, you might need to write multiple versions of the same function or class for different types.</li></ul><p>Example of Loss of Type Safety:</p><pre>function identity(arg: any): any {<br>    return arg;<br>}</pre><h4>Purpose of Generics</h4><ol><li>To maintain the benefits of type checking while allowing components to work with any data type.</li><li>To create more abstract and flexible code.</li></ol><p><strong>Example:</strong> A generic array filter function.</p><pre>function filterArray&lt;T&gt;(array: T[], predicate: (item: T) =&gt; boolean): T[] {<br>    return array.filter(predicate);<br>}</pre><h4>When Not to Use Generics:</h4><ul><li>When the functionality is strictly tied to a single data type and doesn’t require flexibility.</li><li>In simple scenarios where type inference is sufficient.</li></ul><p>Here are good examples of using generics with functions, classes, and interfaces in TypeScript:</p><ol><li>Generic Function</li></ol><p>Example: Identity Function</p><pre>function identity&lt;T&gt;(arg: T): T {<br>    return arg;<br>}<br><br>// Usage<br>const numberIdentity = identity&lt;number&gt;(42);  // Returns 42<br>const stringIdentity = identity&lt;string&gt;(&quot;Hello&quot;);  // Returns &quot;Hello&quot;</pre><p>2. Generic Class</p><p>Example: Generic Stack Class</p><pre>class Stack&lt;T&gt; {<br>    private items: T[] = [];<br><br>    push(item: T): void {<br>        this.items.push(item);<br>    }<br><br>    pop(): T | undefined {<br>        return this.items.pop();<br>    }<br><br>    peek(): T | undefined {<br>        return this.items[this.items.length - 1];<br>    }<br><br>    isEmpty(): boolean {<br>        return this.items.length === 0;<br>    }<br>}<br><br>// Usage<br>const numberStack = new Stack&lt;number&gt;();<br>numberStack.push(1);<br>numberStack.push(2);<br>console.log(numberStack.pop()); // Returns 2<br><br>const stringStack = new Stack&lt;string&gt;();<br>stringStack.push(&quot;Hello&quot;);<br>console.log(stringStack.peek()); // Returns &quot;Hello&quot;</pre><p>3. Generic Interface</p><p>Example: Generic API Response Interface</p><pre>interface ApiResponse&lt;T&gt; {<br>    data: T;<br>    status: string;<br>}<br><br>// Usage<br>const userResponse: ApiResponse&lt;{ id: number; name: string }&gt; = {<br>    data: { id: 1, name: &quot;John Doe&quot; },<br>    status: &quot;success&quot;,<br>};<br><br>const productResponse: ApiResponse&lt;{ id: number; price: number }&gt; = {<br>    data: { id: 1, price: 100 },<br>    status: &quot;success&quot;,<br>};</pre><p><strong>Summary:</strong></p><p>In this article we learned what is Generics in TypeScript.</p><p>Let’s recap:</p><ul><li><strong>Generic Functions</strong> allow you to create functions that work with any data type while keeping type safety</li><li><strong>Generic Classes</strong> provide a way to define data structures (like stacks or queues) that can hold any type.</li><li><strong>Generic Interfaces</strong> allow you to define structures that can adapt to different data types, enhancing reusability.</li></ul><p>Are you eager to expand your knowledge and practice in TypeScript? Begin today and experience the benefits of type safety, reusability, and clarity in your code! If you found this guide helpful, and clearness in your code! share it with your fellow developers and leave a comment below with your thoughts or questions.</p><p>As always, don’t hesitate to ping me if you have any questions here or on twitter (my handle <a href="https://medium.com/u/4c82fce2846c">Imran Younas</a>) and besides that, happy type checking folks and ‘till next time! Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2852587a923b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NestJs @Injectable() Decorator, What is ,Purpose of ,Why Use , How to Use,Background and Impact]]></title>
            <link>https://medium.com/@imranyounaskaa123/nestjs-injectable-decorator-what-is-purpose-of-why-use-how-to-use-background-and-impact-6362e72666d7?source=rss-4c82fce2846c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6362e72666d7</guid>
            <category><![CDATA[nestjs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Imran Younas]]></dc:creator>
            <pubDate>Sun, 11 Aug 2024 12:59:48 GMT</pubDate>
            <atom:updated>2024-08-11T13:38:50.982Z</atom:updated>
            <content:encoded><![CDATA[<h3>NestJs @Injectable() Decorator, What is ,Purpose of ,Why Use , How to Use,Background and Impact</h3><p>Let’s dive deeply into the `<a href="http://twitter.com/Injectable">@Injectable</a>()` decorator in NestJS, covering its purpose, usage, background, and impact.</p><h4><strong>`</strong><a href="http://twitter.com/Injectable"><strong>@Injectable</strong></a><strong>()` Decorator in NestJS</strong></h4><h4><strong>What is `</strong><a href="http://twitter.com/Injectable"><strong>@Injectable</strong></a><strong>()`?</strong></h4><p>- The `<a href="http://twitter.com/Injectable">@Injectable</a>()` decorator in NestJS marks a class as a provider that can be managed by the NestJS dependency injection system.<br>- It essentially tells the NestJS IoC (Inversion of Control) container that this class is a dependency that can be injected into other classes.</p><h4><strong>Purpose of `</strong><a href="http://twitter.com/Injectable"><strong>@Injectable</strong></a><strong>()`</strong></h4><p>- <strong>Identification</strong>: It helps NestJS identify which classes should be treated as providers.<br>- <strong>Dependency Management</strong>: It allows NestJS to manage the lifecycle of the instances of these classes.<br>- <strong>Automatic Injection</strong>: It enables automatic injection of dependencies into constructors of other classes.</p><h4><strong>Why Use `</strong><a href="http://twitter.com/Injectable"><strong>@Injectable</strong></a><strong>()`?</strong></h4><p>- <strong>Modularity:</strong> It promotes modular design by allowing you to break down your application into smaller, reusable components.<br>- <strong>Maintainability:</strong> It makes the codebase easier to maintain by centralizing dependency management.<br>-<strong>Testability:</strong> It improves testability by allowing you to inject mocks or stubs for testing purposes.<br>- <strong>Loose Coupling:</strong> It reduces coupling between classes, making the system more flexible and scalable.</p><h4>How to Use `<a href="http://twitter.com/Injectable">@Injectable</a>()`</h4><blockquote><strong>1. Define a Service (Provider):<br></strong> — You mark a class with `<a href="http://twitter.com/Injectable">@Injectable</a>()` to make it a provider.<br><em> import { Injectable } from ‘</em><a href="http://twitter.com/nestjs/common"><em>@nestjs/common</em></a><em>’;</em></blockquote><blockquote><a href="http://twitter.com/Injectable"><em>@Injectable</em></a><em>()<br> export class CatsService {<br> findAll(): string {<br> return ‘This action returns all cats’;<br> }<br> }</em></blockquote><blockquote><strong>2. Register the Provider in a Module:</strong><br> — You register the provider in a module so that it can be injected into other components within that module.<br> import { Module } from ‘<a href="http://twitter.com/nestjs/common">@nestjs/common</a>’;<br> import { CatsService } from ‘./cats.service’;</blockquote><blockquote><a href="http://twitter.com/Module">@Module</a>({<br> providers: [CatsService],<br> })<br> export class CatsModule {}</blockquote><blockquote><strong>3. Inject the Provider into a Controller:</strong><br> — You inject the provider into the constructor of a class (e.g., a controller).<br> import { Controller, Get } from ‘<a href="http://twitter.com/nestjs/common">@nestjs/common</a>’;<br> import { CatsService } from ‘./cats.service’;</blockquote><blockquote><a href="http://twitter.com/Controller">@Controller</a>(‘cats’)<br> export class CatsController {<br> constructor(private readonly catsService: CatsService) {}</blockquote><blockquote><a href="http://twitter.com/Get">@Get</a>()<br> findAll(): string {<br> return this.catsService.findAll();<br> }<br> }</blockquote><h4><strong>When to Use `</strong><a href="http://twitter.com/Injectable"><strong>@Injectable</strong></a><strong>()`</strong></h4><p>- Use `<a href="http://twitter.com/Injectable">@Injectable</a>()` for any class that provides services, data, or functionality that needs to be shared across different parts of your application.<br>- Common examples include services, repositories, and utility classes.</p><h4><strong>Background and Impact</strong></h4><h4><strong>Background:</strong></h4><p>- <strong>Dependency Injection</strong>: DI is a design pattern that allows a class to receive its dependencies from an external source rather than creating them itself.<br>- <strong>Inversion of Control</strong>: IoC is a principle in which the control of object creation and dependency management is inverted from the class itself to an external container.</p><h4>Impact:</h4><ul><li><strong>Without `</strong><a href="http://twitter.com/Injectable"><strong>@Injectable</strong></a><strong>()`:</strong></li><li>If you do not use `<a href="http://twitter.com/Injectable">@Injectable</a>()`, NestJS will not be able to recognize the class as a provider.</li><li>The class will not be managed by the NestJS IoC container, meaning it cannot be injected into other classes.</li><li>This will lead to errors when trying to use such classes as dependencies in other parts of the application.<br><strong>- With `</strong><a href="http://twitter.com/Injectable"><strong>@Injectable</strong></a><strong>()`:</strong></li><li>The class is registered with the NestJS IoC container.</li><li>It can be injected into constructors of other classes, promoting reusability and maintainability.</li><li>The IoC container manages the lifecycle of the class, ensuring proper initialization and destruction.</li></ul><h4>Example with Explanation</h4><p>Example with a step-by-step explanation:</p><p>1. **Creating a Service (Provider)**:<br> import { Injectable } from ‘<a href="http://twitter.com/nestjs/common">@nestjs/common</a>’;</p><blockquote><a href="http://twitter.com/Injectable">@Injectable</a>() // Marks this class as a provider<br> export class CatsService {<br> findAll(): string {<br> return ‘This action returns all cats’;<br> }<br> }</blockquote><p>- The `CatsService` class is decorated with `<a href="http://twitter.com/Injectable">@Injectable</a>()`, making it a provider.<br> — This allows NestJS to manage its lifecycle and inject it into other components.</p><blockquote><strong>2. Registering the Service in a Module:</strong><br> import { Module } from ‘<a href="http://twitter.com/nestjs/common">@nestjs/common</a>’;<br> import { CatsService } from ‘./cats.service’;<br> import { CatsController } from ‘./cats.controller’;</blockquote><blockquote><a href="http://twitter.com/Module">@Module</a>({<br> providers: [CatsService], // Registers CatsService as a provider<br> controllers: [CatsController],<br> })<br> export class CatsModule {}</blockquote><p>- The `CatsService` is registered in the `CatsModule`.<br> — This makes `CatsService` available for injection within the `CatsModule`.</p><blockquote>3. Injecting the Service into a Controller:<br> import { Controller, Get } from ‘<a href="http://twitter.com/nestjs/common">@nestjs/common</a>’;<br> import { CatsService } from ‘./cats.service’;</blockquote><blockquote><a href="http://twitter.com/Controller">@Controller</a>(‘cats’)<br> export class CatsController {<br> constructor(private readonly catsService: CatsService) {} // Injects CatsService</blockquote><blockquote><a href="http://twitter.com/Get">@Get</a>()<br> findAll(): string {<br> return this.catsService.findAll();<br> }<br> }</blockquote><p>- The `CatsService` is injected into the `CatsController` via its constructor.<br> — This allows `CatsController` to use the `CatsService` to perform its actions.</p><h4>Conclusion</h4><p>The `<a href="http://twitter.com/Injectable">@Injectable</a>()` decorator is crucial in NestJS for enabling dependency injection. It marks a class as a provider, allowing it to be managed by the NestJS IoC container. This facilitates modularity, maintainability, testability, and loose coupling in your application. Without `<a href="http://twitter.com/Injectable">@Injectable</a>()`, the class cannot be injected or managed by the NestJS DI system, leading to potential errors and a more tightly coupled codebase.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6362e72666d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Common use cases for the Singleton pattern in Node.js]]></title>
            <link>https://medium.com/@imranyounaskaa123/common-use-cases-for-the-singleton-pattern-in-node-js-3c2176887068?source=rss-4c82fce2846c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c2176887068</guid>
            <category><![CDATA[encapsulation]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[node-js-tutorial]]></category>
            <category><![CDATA[design-pattern-ios]]></category>
            <category><![CDATA[singleton-pattern]]></category>
            <dc:creator><![CDATA[Imran Younas]]></dc:creator>
            <pubDate>Mon, 24 Apr 2023 07:37:57 GMT</pubDate>
            <atom:updated>2023-04-24T07:49:20.138Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you struggling to manage state or resources in your Node.js application? The Singleton pattern might be just what you need! In this blog post, we’ll explore what the Singleton pattern is, how it works, and how you can use it in your own projects</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YjKAWxp8JDuTpqcvtxHi2Q.png" /></figure><p>The Singleton pattern is a design pattern that allows you to restrict the instantiation of a class to a single instance and provide a global point of access to that instance. In other words, it ensures that only one instance of a particular class exists in a Node.js application and provides a way to access that instance from any part of the application.</p><p>The Singleton pattern solves common problems in Node.js applications by providing a way to manage state and resources more effectively. For example, if you have a resource such as a database connection that needs to be shared across different parts of your application, the Singleton pattern can ensure that there is only one instance of the database connection object and that it is accessible from anywhere in the application.</p><p>Using the Singleton pattern can also help you avoid conflicts and inconsistencies that can arise from multiple instances of a class or object being created. By restricting the instantiation of a class to a single instance, the Singleton pattern ensures that all parts of the application are working with the same instance of the class, avoiding any conflicts or inconsistencies that can arise when different instances of the same class are created.</p><p>To start using the Singleton pattern in your Node.js application, you can create a Singleton class that encapsulates the creation of the object you want to ensure has only one instance. The Singleton class can have a static method that returns the instance of the class, which can be called from any part of the application to get access to the single instance. You can then use this instance to manage state or resources in your application, knowing that there is only one instance of the object.</p><p>Here’s an example of how you might implement a Singleton pattern in Node.js:</p><pre>class Database {<br>  constructor() {<br>    if (Database.instance) {<br>      return Database.instance;<br>    }<br><br>    // Perform initialization tasks here...<br>    this.connection = /* connect to database */;<br><br>    Database.instance = this;<br>  }<br><br>  query(sql) {<br>    return this.connection.query(sql);<br>  }<br>}<br><br>const db = new Database();<br><br></pre><p>In this example, we define a Database class that can only be instantiated once. When we create a new instance of the Database class, we first check whether an instance already exists. If it does, we return that instance instead of creating a new one.</p><p>Inside the constructor of the Database class, we can perform any necessary initialization tasks, such as connecting to a database. We then store a reference to the instance in a static property called instance, which allows us to access the same instance from anywhere in our application.</p><p>To use the Database instance, we simply create a new instance of the class using const db = new Database(). We can then call methods on the db object, such as db.query(’SELECT * FROM users’).</p><p>Here’s another example of how you might implement a Singleton pattern in a Node.js controller:</p><p>class UserController {<br> constructor() {<br> if (UserController.instance) {<br> return UserController.instance;<br> }</p><p>// Perform initialization tasks here...<br> this.users = [];</p><p>UserController.instance = this;<br> }</p><p>getUsers() {<br> return this.users;<br> }</p><p>addUser(user) {<br> this.users.push(user);<br> }<br>}</p><p>const userController = new UserController();</p><p>In this example, we define a UserController class that can only be instantiated once. When we create a new instance of the UserController class, we first check whether an instance already exists. If it does, we return that instance instead of creating a new one.</p><p>Inside the constructor of the UserController class, we can perform any necessary initialization tasks, such as creating an empty array to store users. We then store a reference to the instance in a static property called instance.</p><p>To use the UserController instance, we simply create a new instance of the class using const userController = new UserController(). We can then call methods on the userController object, such as</p><p>userController.addUser({ name: &#39;Alice’, age: 30 }).</p><h3>Conclusion:</h3><p>In conclusion, the Singleton pattern is a powerful tool for managing state and resources in Node.js applications. By restricting the instantiation of a class to a single instance, the Singleton pattern can help you avoid conflicts and inconsistencies, improve code maintainability, and make your applications more efficient. Whether you’re building a small web app or a large-scale enterprise system, the Singleton pattern can help you achieve your goals. So, start using the Singleton pattern today and see the benefits for yourself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c2176887068" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Javascript interview questions and Answers ( Part # 2 ):]]></title>
            <link>https://medium.com/@imranyounaskaa123/javascript-interview-questions-and-answers-part-2-41343f31c84e?source=rss-4c82fce2846c------2</link>
            <guid isPermaLink="false">https://medium.com/p/41343f31c84e</guid>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[Imran Younas]]></dc:creator>
            <pubDate>Sun, 23 Oct 2022 05:07:08 GMT</pubDate>
            <atom:updated>2022-10-23T06:51:36.060Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello readers, in this blog we will discuss javascript interviews questions, you can check out my first part of Javascript interview questions, in this blog I will continue some other important questions you should know If you want become a full Stack javascript developer or want to go into the popular stacks like mern, mean stack. So here is link of my first artical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xaC9GLaZNHjcWSZgMuFgfg.jpeg" /></figure><p>Here is the link 🔗of 1st JavaScript interview questions you can check it out it can help you a lot.</p><p><a href="https://link.medium.com/AxKSeFkH0tb">https://link.medium.com/AxKSeFkH0tb</a></p><h4>. Can we use more than one await keyword with async function?</h4><p>Yes we can use.</p><h4>. What is web storage?</h4><p>Web storage is an API that provides us with web storage by which browsers can store key-value pairs locally within the user’s browser.</p><h4>. Types of methods we used in session storage ?</h4><p>There are 4 main types of methods we used in session storage</p><ol><li>setItem</li><li>getItem</li><li>removeItem</li><li>Clear.</li></ol><h4>. What are the three main states of promises?</h4><ol><li>Pending: pending is an initial state.</li><li>Fulfilled: when the operation was completed.</li><li>Rejection: when we get the error. And the operation did not completed.</li></ol><h4>. Do you know about promise chaining?</h4><p>Yes, when we perform a sequence of asynchronous tasks one after another using promise.</p><h4>. What is the race method in the promise?</h4><p>The race method will return the promised instance that is firstly resolved and reject.</p><h4>. What is the purpose of JSON stringfy?</h4><p>When we send data to a web server the data has to be in string formats. And we can achieve this using the JSON.stringfy method.</p><h4>. And what is the purpose of parse JSON ?</h4><p>When receiving data from the server then the data is always in string formats.</p><h4>Why do we need JSON?</h4><p>Javascript object notation when exchanging data between a browser and a server then the data can only be in text format.</p><h4>Can we define properties for the function ?</h4><p>Yes, we can bcoz the functions are objects.</p><h4>What are the benefits of keeping a declaration at the top?</h4><ol><li>Clear code .</li><li>Single place to look for local variable.</li><li>Avoid duplicate declared variables.</li></ol><h4>How do you define JSON arrays .</h4><h4>How do you generate random integers?</h4><h4>What is the regular expression ?</h4><p>It is a sequence of characters that form a search pattern.</p><h4>What happens if you don’t use rest parameters as a last arguments ?</h4><p>The rest parameters should be in the last argument. The job of the rest parameter is to collect all remaining arguments into an array.</p><h4>How can you get the list of all keys of any object?</h4><p>Using object. key(user) user is an object.</p><h4>What are the various states in Error handling?</h4><p>There are four main statements we always use for handle errors in the program.</p><ol><li>Try: try to test the block of code for errors.</li><li>Catch : use for handle error.</li><li>Throw : by throw we can create custom errors</li><li>Finally: after try-catch finally will be executed.</li></ol><h4>What happens when you write more then one constructor In a class ?</h4><p>You will get unCaught syntax errors. A class may only have one constructor.</p><h4>How do you call the constructor of a parent class?</h4><p>We used the super keyword to access the parent constructor into the child class.</p><h4>Is ENUM features available in JavaScript?</h4><p>No, js doesn’t support the enum feature. Enum is a special data type to be a set of predefined constants. The enum feature will be available in typescript.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41343f31c84e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[7 types of loops in Javascript you should know the interview point of view.]]></title>
            <link>https://medium.com/@imranyounaskaa123/7-types-of-loops-in-javascript-you-should-know-the-interview-point-of-view-6b55a5773082?source=rss-4c82fce2846c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b55a5773082</guid>
            <dc:creator><![CDATA[Imran Younas]]></dc:creator>
            <pubDate>Sat, 22 Oct 2022 15:50:20 GMT</pubDate>
            <atom:updated>2022-10-22T15:56:07.614Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello readers. When we talk about programming languages then loops play an important role in the project for reputation some task in multiple times and will get different values as per your logic. do you know in javascript there are 7 important loops we always used for projects? In this article, we will go through different ways of looping in JavaScript with the help of e.g.</p><h4>7 loops in JavaScript :</h4><ol><li>For loop</li><li>while loop</li><li>Do while loop</li><li>For each loop</li><li>map</li><li>For of loop</li><li>For in loop.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MOYJZ07npQzv4HhHBzDPcA.jpeg" /></figure><ul><li><strong>For loop</strong> :</li></ul><p>For loop is used to repeat a specific task that is in a block of code and you don’t know end index of the loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*J7b6pQRATY4bl5bZy5ueOQ.jpeg" /></figure><p>You can see in the above expression, in for loop we used 3 statements 1. The initial value is where we declare the initial part.2. Condition we use logical condition that till this condition will false loop will terminate. 3 update here initial value update like increment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*UJuw5uxQCPpuV-HKz3zhfw.jpeg" /></figure><ul><li><strong>while loop:</strong></li></ul><p>while loop first check the condition as long as condition is true then while loop will take action. When you don’t know the end point then you can use while loop. All program relay on just condition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*QzH-sxxdYQRlj732JEPTXg.jpeg" /></figure><p>You can see in the given syntax of the while loop, we initially set the condition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*16Ce3BpkfRY2gxpzSkUSDA.jpeg" /></figure><ul><li><strong>Do while loop</strong></li></ul><p>Do while loop executes body at least once whether our condition is true or false. Also called the exit control loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*pvMgdr-TyAJi4WWk6NcSng.jpeg" /></figure><p>E.g</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*aJZ0a6XGdKQhIy31Bc9hMQ.jpeg" /></figure><ul><li><strong>For each loop</strong></li></ul><p>Purpose of the forEach loop iterates items in a collection. we used for traversing each item one by one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*6VY_k_0zelkEwMMYVHDxNw.jpeg" /></figure><p>E.g</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*4L5NulqjXu_cP7yAHW4QxQ.jpeg" /></figure><ul><li><strong>map</strong></li></ul><p>The map method is used to iterate over an array and we can modify elements using call back function. And map method creates a new array and doesn’t affect the existing array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*WRpLH7vxseR1Y__fM0mhjw.jpeg" /></figure><p>E.g</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*7S4sEss-Q9Z-bFeA0YXaZw.jpeg" /></figure><ul><li><strong>For of loop</strong></li></ul><p>For of loop returns a list of values of an iterable object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*wSARb1TkQrgj6dBkRzm6-g.jpeg" /></figure><p>E.g</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*bA3CXapIqy0wmzcML4mAdA.jpeg" /></figure><ul><li><strong>For in loop.</strong></li></ul><p>For in-loop iterates of all properties key of an object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*V1l8dWJrz_StCiCTylEWSg.jpeg" /></figure><p>E.g</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*i5P4auPBI6gOV_4em0nCOg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b55a5773082" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a react js sidebar using Hooks and routers.]]></title>
            <link>https://medium.com/@imranyounaskaa123/create-a-smartly-react-js-sidebar-using-hooks-and-routers-cc3d0a50cae5?source=rss-4c82fce2846c------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc3d0a50cae5</guid>
            <category><![CDATA[reactjs-tutorial]]></category>
            <category><![CDATA[tips-and-tricks]]></category>
            <category><![CDATA[menu]]></category>
            <category><![CDATA[sidebar-menu]]></category>
            <category><![CDATA[react-js-development]]></category>
            <dc:creator><![CDATA[Imran Younas]]></dc:creator>
            <pubDate>Tue, 18 Oct 2022 17:39:37 GMT</pubDate>
            <atom:updated>2022-10-21T03:01:29.873Z</atom:updated>
            <content:encoded><![CDATA[<p>For beginners, it’s hard to create a sidebar or menu in react js. In starting I searched a lot about how can I easily do this task and understand it. So today in this blog I will tell you how can we create a simple sidebar in react js. You will learn how can we use the data in the Link tag using react-router-dom. we will create pages of data that are used in the array map function by this we can reuse our code and minimize it as well.</p><p>Before we start coding you should install these npm packages.</p><p>&quot;react-icons&quot;: &quot;^3.10.0&quot;, &quot;react-router-dom&quot;: &quot;^5.2.0&quot;,</p><p>Create 2 folders 📂 one component and the other one is pages. In the pages folder, you just create pages like home, about, contact, blogs, and so on. And in the Components folder create 3 files e.g Navbar.css, Navbar.js, and SideBarData.jsx.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gcX_IgI1drKm5KIcxw40xA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*S2OksTZ_G_N5IYMNBep-1w.jpeg" /></figure><p><strong>Components :&gt; SidebarData.jsx:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*HFTqmcFRND7Tctny3y4FFA.png" /></figure><p>In the sidebar.jsx I added links data I will call it dynamically. Through this, we can achieve reusability.</p><p>Components :&gt; Navbar.jsx:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RBW0gX5M6GHEitZbCpRSYA.png" /></figure><p>If you know basic react js and did the project you can understand the above code. Initially, I set the sidebar false</p><p><strong>Components :&gt; Navbar.css:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*yQizT4QVsN0baOvuPWCrOg.png" /></figure><p>Pages :&gt; home.jsx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*XSYiZohYuMuVs96CCkyGEw.png" /></figure><p>Pages :&gt; reports.jsx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*s0Vm8ML5Y8_z9eyeHyABLA.png" /></figure><p>Pages :&gt; Products.jsx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*JEs0305knYvqm7cVGWzvvw.png" /></figure><p>App.jsx</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kyz10GxAkZqUOjwT8wykIQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc3d0a50cae5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 react js basic coding challenges that can help you to create projects.]]></title>
            <link>https://medium.com/@imranyounaskaa123/10-react-js-basic-coding-challenges-that-can-help-out-you-to-create-projects-a90ed9493114?source=rss-4c82fce2846c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a90ed9493114</guid>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[react-js-tutorials]]></category>
            <category><![CDATA[tips]]></category>
            <category><![CDATA[challenge]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Imran Younas]]></dc:creator>
            <pubDate>Mon, 17 Oct 2022 17:10:50 GMT</pubDate>
            <atom:updated>2022-10-17T17:44:25.464Z</atom:updated>
            <content:encoded><![CDATA[<p>When we learn to react js then we can’t understand at starting and sometimes we feel like we can’t create react projects. We don’t believe to create projects and always doubt we couldn’t do the client projects. So today I will share with you 5 react js challenges. If you do these challenges by yourself then it will be easy to create projects in react js.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V_9YbY81qDz2-2pAxd8Y4A.jpeg" /></figure><h4>1. Challenge one:</h4><p>In this challenge, you have to display jsx. Use the dummy data and how can we use that data using an array map function in the jsx. Use some logic e.g ternary operator with jsx. Pass the data using props and use that data with jsx and you can do more things with jsx.</p><h4>2. Display data using array map function.</h4><p>This challenge will help you in every project. And every time we use the data from the backend using array map functions. It’s an easy task but will help you a lot.</p><h4>3. Show hide data.</h4><p>You have to use useState() for this challenge. You can also understand how useState() work. And I am giving you some task. Like creating a password input and adding show hide text. When you click this text, the password should be shown and when you click hide then your password should show hide. 2 task is to use the toggle menu.</p><h4>4. Create a counter :</h4><p>Counter app. It’s an easy task you can do.</p><h4>5. Fetch data from API.</h4><p>You can you use GitHub public apis and use for this challenge. You just learn how to fetch data in react js and use that data using array map function. Should display data in the ui.</p><p>Don’t worry I will add more challenges to this blog. You will be confident more in react js.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a90ed9493114" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React js Roadmap to become a React js developer. ]]></title>
            <link>https://medium.com/@imranyounaskaa123/react-js-roadmap-to-become-a-react-js-developer-dd535968b686?source=rss-4c82fce2846c------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd535968b686</guid>
            <category><![CDATA[react-js-development]]></category>
            <category><![CDATA[react-js-tutorials]]></category>
            <category><![CDATA[react-js-training]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[roadmaps]]></category>
            <dc:creator><![CDATA[Imran Younas]]></dc:creator>
            <pubDate>Sun, 16 Oct 2022 16:42:47 GMT</pubDate>
            <atom:updated>2022-10-16T17:08:50.495Z</atom:updated>
            <content:encoded><![CDATA[<p>As you know react is a popular library that’s why I thought should I create react js roadmap so that you can benefit from it. In this article, I will give a full roadmap of react js and explain to you which part you should focus on more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UKcpy_AQVd4HmC7J0GRGfA.jpeg" /></figure><ol><li>React fundamentals</li><li>React beyond basics</li><li>React libraries /ecosystem</li><li>Debugging</li><li>Testing</li><li>Practice projects and components.</li></ol><h3>React fundamentals :</h3><ul><li><strong>Components in react</strong>:</li></ul><p>There are two types of components in react js 1. Functional component and 2. Class components. Mostly we used functional components. We can reuse code by components.</p><ul><li><strong>State and Props:</strong></li></ul><p>State and props are a heart of a react component.</p><ul><li><strong>JSX:</strong></li></ul><p>The best thing in reacts js. In jsx, we can use js with HTML.</p><ul><li><strong>Styling :</strong></li></ul><p>We can use CSS in 3 ways. 1. Inline 2. Module 3. CSS file.</p><ul><li><strong>Basic Hooks</strong></li></ul><ol><li>useState()</li><li>useEffect()</li></ol><ul><li><strong>Conditional rendering.</strong></li></ul><p>We use the tourney operator in react js.</p><ul><li><strong>List and keys:</strong></li><li><strong>Form basic</strong> :</li></ul><ol><li>Controlled components</li><li>Uncontrolled components</li></ol><ul><li><strong>Composition</strong></li></ul><p>You should practice the above fundamentals topics then you go ahead. If you don’t understand fundamental topics then you can’t understand the advance topics.</p><h3>React beyond basics :</h3><ul><li><strong>All Hooks:</strong></li></ul><ol><li>useState()</li><li>useEffect()</li><li>useRef()</li><li>useContext()</li><li>useMemo()</li><li>useCallback()</li><li>How we can create custom hooks.</li></ol><ul><li><strong>Context API</strong></li><li><strong>Code splitting</strong></li><li><strong>Error boundaries</strong></li><li><strong>Static type checking</strong></li><li><strong>Refs</strong></li><li><strong>Poetal</strong></li><li><strong>Profiler</strong></li><li><strong>Reconciliation</strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd535968b686" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the best way to solve programming Errors?]]></title>
            <link>https://medium.com/@imranyounaskaa123/what-is-the-best-way-to-solve-programming-errors-f4e35fa8c85c?source=rss-4c82fce2846c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4e35fa8c85c</guid>
            <category><![CDATA[tips]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[bugs]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[error]]></category>
            <dc:creator><![CDATA[Imran Younas]]></dc:creator>
            <pubDate>Sun, 16 Oct 2022 14:58:26 GMT</pubDate>
            <atom:updated>2022-10-16T15:09:19.809Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, I will discuss errors you can face when you are working on a project. I faced a lot of errors during my programming and learning journey. Even I spent 2, or 3 weeks solving the error. I know it’s irritating things. But when you solved the error by own self then you can’t forget that error ever. There are two errors we always face</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opj-LLm9xui2G3w4dXhMaw.jpeg" /></figure><ol><li>Syntax errors</li><li>Logical errors.</li></ol><p>A syntax error is generally identified by your compiler or interpreter.</p><p>It’s hard to solve logical errors. I always follow these processes when I faced some logical errors in a programming language.</p><h4>Understand the whole requirement:</h4><p>When you face logical error then you should understand what exactly our project is. You know the features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*A8-Ff9myEGQBzQmoJJP44Q.jpeg" /></figure><h4>Indent code properly :</h4><p>Indent code you can better understand the code and easier to solve the error.</p><h4>Understand the code by reading:</h4><p>an important part you should understand by reading the code. By reading you will know the whole program starts to end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*IqKhBihQbkO8jywCuVQKtw.jpeg" /></figure><h4>Break the code :</h4><p>You can break the code into chunks like small functions and specific classes. It will be easy to deal with errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*l0iucfgmPQtJlf-q3ZoAWQ.jpeg" /></figure><h4>Reuse the code :</h4><p>You should reuse your code as possible as, it removes redundant code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*PYzICCz08rFhsRX7oYWBxw.jpeg" /></figure><h4>Run the code:</h4><p>Every time you change the code then you should run it and compare the output</p><h4>Comments:</h4><p>When you face any issue you can comment there. It will help you when you face the same error.</p><p>By following these steps I would have identified the source. if the problem. I correct that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*U4eiv0Q6o-Jx3hbm2Knj1A.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4e35fa8c85c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ES6(EchmaScript-6) all concepts you should know If you want crack your JavaScript inteview.]]></title>
            <link>https://medium.com/@imranyounaskaa123/es6-echmascript-6-all-concepts-you-should-know-if-you-want-crack-your-javascript-inteview-69cb884340a6?source=rss-4c82fce2846c------2</link>
            <guid isPermaLink="false">https://medium.com/p/69cb884340a6</guid>
            <category><![CDATA[es6]]></category>
            <category><![CDATA[answers]]></category>
            <category><![CDATA[crack]]></category>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Imran Younas]]></dc:creator>
            <pubDate>Thu, 13 Oct 2022 07:34:08 GMT</pubDate>
            <atom:updated>2022-10-13T07:36:37.044Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QwKe6e-V6JYoHJXDwz6erA.jpeg" /></figure><p>70% interviewer ask questions related to ES6 which is EchmaScript-6 is the new version of Javascript. If you want to learn react js then you should learn ES6 topics. I will share you the most important questions.</p><h4>. What is the purpose of EchmaScript?</h4><p>ES6 represents the scripting language specification, ES6 gives you new syntax and features so that your code could be more readable. In ES6 there are amazing features that allow us to write less code.</p><h4>2.1. Let keyword in ES6.</h4><p>In ES6 we can declare a variable in a new way by using the let keyword. These variables are blocked-scope. Blocks are denoted by curly braces E.g if-else, for, try-catch.</p><h4>2.1 const variable in ES6</h4><p>ES6 provides a new way of declaring variables by using the const keyword. We can not reassign the const variable. you can change the value of its property.</p><h4>2.3 default function parameter.</h4><p>In ES6 we can initialize default value parameters in a function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*3NVukMmDk7fd594hvpmrOw.png" /></figure><h4>Rest parameter in ES6:</h4><p>The job of the rest parameter is to collect the remaining argument in the array. One thing you should know is only the function’s last parameter can be the rest parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*x8v1G9i_WWIScguUvoTRSw.png" /></figure><h4>Template literals in ES6:</h4><p>In ES6 we can work with strings in a new way compared to ES5 using a template literal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*7x7gr2z1WKyKVECa7-9Hug.png" /></figure><h4>Classes :</h4><p>In ES6 we can create classes if you are familiar with different languages like java, python then you know how we use classes. Class is just like a template or structure so that we could create objects later. The constructor() method is responsible for the initialization of objects. And methods() represent actions that object actions take place.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*RPjv3nsBrEnqCN96ONJzwQ.png" /></figure><h4>Inheritance:</h4><p>When we used parents in child class then inheritance comes into play. Want to create an instance class, use the extends keywords. We used super() methods in the constructor to access all parent properties and methods in the child class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*01iSAIAFVe9sSZV97Kb4Kg.png" /></figure><h4>What is the generator in ES6?</h4><p>In ES6 generator is a function. And we used the star symbol after the function keyword. And one special keyword yield which is the same as the return keyword. This function returns an iterator object and the next() method returns an object. It gives the output sequence way. Generator function used in data streams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*0NFBS1dABkQEIJ3W-cCO4g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69cb884340a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>