<?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 Deepa Chaurasia on Medium]]></title>
        <description><![CDATA[Stories by Deepa Chaurasia on Medium]]></description>
        <link>https://medium.com/@deepachaurasia33?source=rss-75811fd81393------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aHBvHMN3WfPakFQLLIj6IQ.jpeg</url>
            <title>Stories by Deepa Chaurasia on Medium</title>
            <link>https://medium.com/@deepachaurasia33?source=rss-75811fd81393------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 04:14:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@deepachaurasia33/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[Angular Interview Coding Question]]></title>
            <link>https://medium.com/@deepachaurasia33/angular-interview-coding-question-e76aec3fde2e?source=rss-75811fd81393------2</link>
            <guid isPermaLink="false">https://medium.com/p/e76aec3fde2e</guid>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Deepa Chaurasia]]></dc:creator>
            <pubDate>Fri, 24 Nov 2023 09:40:03 GMT</pubDate>
            <atom:updated>2023-11-24T09:40:03.094Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to share data between sibling components in Angular?</h3><p><em>Let’s say you have a component called First. Inside first component you have a button named increment.</em></p><p>There’s another component second , <strong>inside this you have a variable named count=0 .</strong></p><p>Now what interviewer wants <strong>if you click on increment button in first component , the count variable must increment in second component and reflect the same</strong>.</p><h3>How you will achieve it???</h3><pre>import &#39;zone.js/dist/zone&#39;;<br>import { Component } from &#39;@angular/core&#39;;<br>import { CommonModule } from &#39;@angular/common&#39;;<br>import { bootstrapApplication } from &#39;@angular/platform-browser&#39;;<br>import { AppService } from &#39;./app.service&#39;<br><br>@Component({<br>  selector: &#39;my-first&#39;,<br>  template: `<br>    &lt;h1&gt;First&lt;/h1&gt;<br>    &lt;button&gt;Increment&lt;/button&gt;<br>  `,<br>  standalone: true,<br>  imports: [CommonModule],<br>})<br>export class First {<br>  name = &#39;Angular&#39;;<br>}<br><br>@Component({<br>  selector: &#39;my-second&#39;,<br>  template: `<br>    &lt;h1&gt;Second&lt;/h1&gt;<br>    &lt;h2&gt;{{count}}&lt;/h2&gt;<br>  `,<br>  standalone: true,<br>  imports: [CommonModule],<br>})<br>export class Second {<br>  count: number = 0;<br>  name = &#39;Angular&#39;;<br>}<br><br><br><br>@Component({<br>  selector: &#39;my-app&#39;,<br>  standalone: true,<br>  imports: [First, Second, CommonModule],<br>  providers: [AppService],<br>  template: `<br>    &lt;h1&gt;Hello from {{ name }}!&lt;/h1&gt;<br>    &lt;a target=&quot;_blank&quot; href=&quot;https://angular.io/start&quot;&gt;<br>      Learn more about Angular<br>    &lt;/a&gt;<br>    &lt;my-first&gt;&lt;/my-first&gt;<br>    &lt;my-second&gt;&lt;/my-second&gt;<br>  `,<br>})<br>export class App {<br>  name = &#39;Angular&#39;;<br><br>  constructor(private appService: AppService) {<br>      console.log(this.appService.getData())<br>  }<br>}<br><br><br>bootstrapApplication(App);</pre><p>Here’s the code .<br>Link to Question -<a href="https://stackblitz.com/edit/stackblitz-starters-bxdzcr?file=src%2Fmain.ts">https://stackblitz.com/edit/stackblitz-starters-bxdzcr?file=src%2Fmain.ts</a></p><p>Answer :</p><p>There could be multiple approaches to achieve the same . But what i find easiest is through services.</p><p><strong>Services in angular is used to establish a communication between the components who don’t have parent child relationship and are completely different.</strong></p><p>Here in above interview question <strong>first and second both are sibling components</strong>. Therefore you will use service here.</p><ul><li>First you will <strong>create a service (i.e app.service.ts)</strong> here.</li><li>Second you will <strong>create two methods inside it, one is to get updated data (i.e getData())</strong> , then the increment the count number that will be shared between two sibling component. We will create <strong>incrementData()</strong> method for this.</li><li>Now you will have to <strong>create a subject count</strong> , that you are going to subscribe to get updated value every time increment button is clicked.</li></ul><p><strong>Subjects are the kind of observable that gives you updated value consistently after every change. You can call next method to get updated value.</strong></p><p>That’s how your code should look like</p><pre>import { Injectable } from &#39;@angular/core&#39;;<br>import { Subject } from &#39;rxjs&#39;;<br><br>@Injectable()<br>export class AppService {<br>  constructor() {}<br><br>  count = new Subject&lt;number&gt;();<br><br>  incrementData(count: number) {<br>    this.count.next(count);<br>  }<br><br>  getData() {<br>    return this.count;<br>  }<br>}</pre><ul><li>Now in first component you have to create a method that will call on every click of increment button.</li></ul><p>Remember <strong>first step is initialise service inside constructor and then use it later to access service method</strong></p><pre>@Component({<br>  selector: &#39;my-first&#39;,<br>  template: `<br>    &lt;h1&gt;First&lt;/h1&gt;<br>    &lt;button (click)=&quot;incrementData()&quot;&gt;Increment&lt;/button&gt;<br>  `,<br>  standalone: true,<br>  imports: [CommonModule],<br>})<br>export class First {<br>  name = &#39;Angular&#39;;<br>  count: number = 0;<br><br>  constructor(private appService: AppService) {}<br><br>  incrementData() {<br>    this.appService.incrementData(this.count++);<br>  }<br>}</pre><ul><li>Now in Second Component <strong>you have subscribe to the subject created in service and update value</strong></li></ul><pre>@Component({<br>  selector: &#39;my-second&#39;,<br>  template: `<br>    &lt;h1&gt;Second&lt;/h1&gt;<br>    &lt;h2&gt;{{count}}&lt;/h2&gt;<br>  `,<br>  standalone: true,<br>  imports: [CommonModule],<br>})<br>export class Second {<br>  constructor(private appService: AppService) {<br>    this.appService.getData().subscribe((data) =&gt; {<br>      console.log(data);<br>      this.count = data;<br>    });<br>  }<br>  count: number = 0;<br><br>  name = &#39;Angular&#39;;<br>}</pre><p>That’s how you will do it .</p><p>Full code for answer is here :<a href="https://stackblitz.com/edit/stackblitz-starters-gv2eui?file=src%2Fmain.ts">https://stackblitz.com/edit/stackblitz-starters-gv2eui?file=src%2Fmain.ts</a></p><p>Let me know if you have more ways to do it in comments.</p><p><em>Thanks for reading, do share if it helps you</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e76aec3fde2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Change Detection in Angular?]]></title>
            <link>https://medium.com/@deepachaurasia33/what-is-change-detection-in-angular-84f960c66d0a?source=rss-75811fd81393------2</link>
            <guid isPermaLink="false">https://medium.com/p/84f960c66d0a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Deepa Chaurasia]]></dc:creator>
            <pubDate>Sat, 27 May 2023 13:48:46 GMT</pubDate>
            <atom:updated>2023-05-27T13:48:46.758Z</atom:updated>
            <content:encoded><![CDATA[<p>Change detection is <strong>detecting changes in any component </strong>of your app and re-render view, so it displays updated value to end users.</p><p>Different events on which change occurs:</p><ul><li>Data received from network requests or component events.</li><li>Mouse clicks,scrolling,mouseover,keyboard navigation</li><li>AJAX Calls</li><li>Use of timer function such as setTimeout() or setInterval().</li></ul><h3>How does Change detection work??</h3><ul><li>Whenever something triggers a change.</li><li>To detect and update DOM with changed data,the framework provides its own change detection detector for each component.</li><li>The change detector make sure data model and DOM are in sync.</li><li>When Angular change detection detects the triggered change and run change detection to all component tree from top to bottom.</li></ul><h3>Angular Change Detection strategies</h3><p>There are two strategies basically in angular:-</p><ul><li>Default Change Detection Strategy</li><li>OnPush Change Detection Strategy</li></ul><h3>Default Change Detection Strategy</h3><p>If <strong>Angular Change Detector</strong> is set to default then for any change in any model property, Angular will run change detection traversing component tree to update DOM.</p><p><strong>Change Detector Ref</strong> class provides few built in methods , we can use to manipulate change detection tree.</p><ul><li><strong>markForCheck()</strong> — marks that it changed.</li><li><strong>detach()</strong> — exclude view from change detection tree</li><li><strong>detect Changes()</strong> — check view and its child component</li><li><strong>checkNoChanges()</strong> -check view and it’s child ,throw error if changes detected.</li><li><strong>reattach()</strong> — reattach a view that was previously detached</li></ul><h3>Angular OnPush Change Detection Strategy</h3><p>If angular change detector is set to <strong>onPush</strong> then Angular will run change detector only when new reference is being passed to component.</p><p>If observable is passed to onPush, then changeDetector must be called manually to update DOM</p><p><strong>Benefits</strong></p><p><strong>Unnecessary check in child not performed </strong>if parent element updating values which are not passed @Input</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H39rDhb8B0eHaDuCi-PWrQ.png" /><figcaption>onpush change detection strategy</figcaption></figure><p>Here we have changed strategy to OnPush</p><p><em>Hope it help you guys :)</em></p><p><em>Please like share and subscribe if you like it</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84f960c66d0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hoisting in JavaScript]]></title>
            <link>https://medium.com/@deepachaurasia33/hoisting-in-javascript-18eb10bbb57f?source=rss-75811fd81393------2</link>
            <guid isPermaLink="false">https://medium.com/p/18eb10bbb57f</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Deepa Chaurasia]]></dc:creator>
            <pubDate>Thu, 16 Mar 2023 18:48:42 GMT</pubDate>
            <atom:updated>2023-03-16T18:48:42.894Z</atom:updated>
            <content:encoded><![CDATA[<p>Hoisting simple gives <strong>higher specificity to javascript declarations.</strong> Thus, it makes the computer read and process declarations first before analyzing other code in program.</p><p>Note: Hosting does not mean JavaScript rearranges or move code above one anothers.</p><p>E.g.</p><pre>console.log(name); <br>// Uncaught ReferenceError: name is not defined<br>let name = &#39;Deepa&#39;;</pre><ul><li>variables declared with let and const are hoisted but not initialized with a default value.</li><li>Accessing let or const before it’s declared will give: Uncaught ReferenceError: can’t access before initialization</li><li>Remember the error message tells variable is initialized somewhere.</li></ul><h3>Variable hoisting with var</h3><p>When interpreter hoists a variable declared with var, it initialized its value to undefined, unlike let or const.<br>E.g.</p><pre>console.log(name); // undefined<br>var name = &#39;deepa&#39;;<br>console.log(name); // deepa</pre><p>Now let’s analyze this behaviour:</p><pre>var name;<br>console.log(name); // undefined<br>name = &#39;partha&#39;;<br>console.log(name); // partha</pre><p>Remember, the first console.log(name) outputs <strong>undefined because name is hoisted</strong>, and given a default value (not because variable is never declared).</p><p><strong>Using undefined variable will throw ReferenceError</strong></p><p>console.log(name); // Uncaught ReferenceError: name is not defined</p><p>Now let’s see if we don’t declare var what happens.</p><p>console.log(name); // partha<br>name = &#39;partha&#39;;</p><p>name = assigning a variable that’s not declared is valid.</p><p><strong>JavaScript let us access variable before they’re declared.</strong> This behaviour is an unusual part of javascript and can lead to errors.</p><p>Using variable before it’s declaration is not desirable.</p><p>The reason why we get reference error when we try to access let or const before its declaration is <strong>Temperal Dead Zone</strong></p><ul><li>The TDZ starts at beginning of the variables enclosing scope and ends when it is declared.</li><li>Accessing variable in TDZ gives ReferenceError</li></ul><p>E.g.</p><pre><br>    // start of foo&#39;s TDZ<br>    let bar = &#39;bar&#39;;<br>    console.log(bar); // bar<br>    console.log(foo); // ReferenceError: Because we&#39;re in TDZ<br>    let foo = &#39;foo&#39;;<br>    // end of foo&#39;s TDZ<br></pre><ul><li>type of TDZ for let or const: ReferenceError</li><li>type of TDZ for var: undefined</li></ul><h3>Functional Hoisting</h3><p>Function declarations are hoisted too. Function hoisting allows us to call function before it is declared or defined.</p><pre>foo(); <br>function foo() {<br>    console.log(&#39;foo&#39;); // foo<br>}</pre><p>Note: only function declaration are hoisted not function expressions.</p><p>E.g.</p><pre>foo(); // Uncaught TypeError: foo is not a function<br>var foo = function() {<br><br>}<br><br>bar(); // Uncaught ReferenceError<br>let bar = function() {<br><br>}</pre><p><strong>Uncaught ReferenceError</strong>: can’t access ‘bar’ before initialization similarly for const.</p><p>For function that is never declared:</p><pre>foo(); // Uncaught ReferenceError: foo is not defined</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18eb10bbb57f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Devfest Experince as Speaker]]></title>
            <link>https://medium.com/@deepachaurasia33/my-devfest-experince-as-speaker-485129f48ac3?source=rss-75811fd81393------2</link>
            <guid isPermaLink="false">https://medium.com/p/485129f48ac3</guid>
            <dc:creator><![CDATA[Deepa Chaurasia]]></dc:creator>
            <pubDate>Sun, 11 Dec 2022 18:50:29 GMT</pubDate>
            <atom:updated>2022-12-11T18:50:29.105Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://dev.to/t/webdev">#webdev</a><a href="https://dev.to/t/javascript">#javascript</a><a href="https://dev.to/t/devfest">#devfest</a><a href="https://dev.to/t/programming">#programming</a></p><p>Hello everyone , I generally post about angular and tech related stuff only . However what i want to share today is also pretty much about tech event only.</p><p><strong>Today I had my first ever Event of DevFest as Speaker </strong>. <em>What made me write this blog is to share my experience and motivate other tech enthusiast to come forward and become speaker at such events.</em></p><p>Let me count you the reasons why you must be at such events:</p><ul><li>All the attendes present there are genuinely attentive and are willing to learn something new.</li><li>You get great vibes from everywhere around</li><li>It’s the platform to give back to your community.</li><li>It gives you the recognition in the industry as well.</li></ul><p><em>I have attended the devfest Noida where most of the attendes were student. These students were not just immensly talented but the great audience as well.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*u2dCxOFYoReyCbki.jpg" /></figure><p><em>I really liked the respect they have for speakers and will to gain more and more knowledge .What i have realised is these students realise importance of knowledge and that’s why they are valued everywhere.</em></p><p><strong>What have become pretty common these days is not respecting your teacher.I was pretty impressed with my audience out there</strong></p><p>Apart from that I got the chance to meet amazing tech leaders from big companies. Their insights will be life long lesson for me . Meeting such great personaties and sharing stage with them is a blessing for me .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*qKsY8efwlS-FkA4m.jpg" /></figure><p><strong>From my childhood ,I have felt the most confident on stage .You will be shocked to know I am an under confident person in real life . But an over confident person on stage</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*TA5ImDKkcqqJbsZN.jpg" /></figure><p><strong>THIS IS ME ,CONFIDENT ON STAGE :)</strong></p><p><em>I don’t know something’s really wrong here but that’s how it is.</em></p><p><strong>Apart from this the level of efforts volunteers give to make these events a success is just incredible . People were comparing #devfestNoida with international events.Their team work was pretty awesome. We can see what team work can do after these success events</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*TlspATTvuNXgwBAd.jpg" /></figure><p>And let me tell you these volunteers were the college students.The organizers were also young but pretty wise at taking decisions and executing the event.</p><p><strong>One must always participate at such events as a volunteer,attendee,speaker or Organizer itself because it actually pushes you to develop the qualities you were not aware you had.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=485129f48ac3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to show or hide component on basis of Route in Angular.]]></title>
            <link>https://medium.com/@deepachaurasia33/how-to-show-or-hide-component-on-basis-of-route-in-angular-a5c691b099fa?source=rss-75811fd81393------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5c691b099fa</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-develop]]></category>
            <dc:creator><![CDATA[Deepa Chaurasia]]></dc:creator>
            <pubDate>Wed, 30 Nov 2022 08:14:09 GMT</pubDate>
            <atom:updated>2022-11-30T08:14:09.269Z</atom:updated>
            <content:encoded><![CDATA[<p>As a Frontend developer,You come across a situation where you have to show a component only if you navigate to dashboard,or your login component.For rest you must hide.</p><p><strong>How are you going to manage all of this in angular??</strong></p><p><em>Well Angular provides you a various events and properties of router that you can use to track on which router user is currently at.</em></p><p><strong>We will be discussing NavigationEnd event of Angular route</strong></p><h3>What is Navigation End??</h3><p><strong>An event triggered when a navigation ends successfully.</strong></p><h3>How to Use??</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*e6Jm1D3_p_LF2rRLpdxZ9g.png" /></figure><ul><li>Inside constructor you subscribe to router events.</li><li>Then you will check subscribed val is an instance of Navigation End or not .</li><li>If yes then you will use that subscribed value and use value.url to find the url where user has navigated currently and put logic inside.</li><li>At last you will write your logic according to value.url</li></ul><p>In the example above I have wrote logic to not show header on login , else on all other components whether dashboard,or any other headers will be visible.</p><p>My app.component.html looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*sUOE6hGpc7L82GCK.png" /></figure><p><em>Here you can see I am showing header only if “showHeader” property is true</em></p><p>My app.component.ts looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*wlzpclsJ0dU2MoSL.png" /></figure><p><strong>Now If i click on submit button it will route to ‘dashboard’<br>and shows dashboard component.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*tbsaBioRWYomqeUn.png" /></figure><p>*<em>Therefore header component becomes visible *</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*EfiWntQaAtaHhT0D.png" /></figure><p>The working respository for reference<br><a href="https://stackblitz.com/edit/angular-ivy-atods7?file=src/app/app.component.ts">https://stackblitz.com/edit/angular-ivy-atods7?file=src/app/app.component.ts</a></p><p>Github Link<br><a href="https://github.com/deepa314/angular-ivy-atods7.git">https://github.com/deepa314/angular-ivy-atods7.git</a></p><p><em>I hope it help you guys :)</em><br><strong>If you like please like ,share and subscribe</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5c691b099fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Possible ways to send data through Routing in Angular]]></title>
            <link>https://medium.com/@deepachaurasia33/possible-ways-to-send-data-through-routing-in-angular-f1f72742c2da?source=rss-75811fd81393------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1f72742c2da</guid>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[webdesign-and-development]]></category>
            <dc:creator><![CDATA[Deepa Chaurasia]]></dc:creator>
            <pubDate>Sat, 19 Nov 2022 05:32:15 GMT</pubDate>
            <atom:updated>2022-11-19T17:50:46.866Z</atom:updated>
            <content:encoded><![CDATA[<p>While developing the large-scale applications,You may often came up with the scenarios where you want to send data through routing parameters. I will discuss all possible ways to do the same.</p><h3>NAVIGATION AND ROUTE PARAMS</h3><p>We can send data through navigation, and most often we use this method .</p><p><strong>How to use it??</strong></p><ul><li>Step 1: In your routing module, set up your routes with the params you wanna send.</li></ul><pre>import { NgModule } from &#39;@angular/core&#39;;<br>import { RouterModule, Routes } from &#39;@angular/router&#39;;<br>import { RoleUserMapComponent } from &#39;./role-user-map.component&#39;;<br><br>const routes: Routes = [<br>  { path: &#39;&#39;, component: RoleUserComponent },<br>  { path: &#39;add&#39;,component:RoleUserAddComponent },<br>  { path: &#39;edit/:userId&#39;,component:RoleUserEditComponent },<br>  { path: &#39;detail/:userId&#39;, component:RoleUserDetailComponent <br>];<br><br>@NgModule({<br> imports: [RouterModule.forRoot(routes, { useHash: true })],<br> exports: [RouterModule],<br> providers: []<br>})<br>export class AppRoutingModule { }</pre><p><em>Here in my path, i have attached ‘userId’ as param ,which will subscribe later from detail and edit component</em></p><ul><li>Step 2:Now you will set the navigation either through navigator method or directly through routerLink</li></ul><p><strong>Using routerLink</strong></p><pre>&lt; a [routerLink]=&quot;[&#39;/edit&#39;,userId]&quot;&gt;Edit&lt;/a&gt;</pre><p><strong>Using navigator</strong></p><pre>this.router.navigate([&#39;edit&#39;, userId]);</pre><ul><li>Step 3:It’s time to subscribe the params we have passed inside our edit/details component</li></ul><pre>@Component({<br>  selector: &#39;app-role-user-map-edit&#39;,<br>  templateUrl: &#39;./role-user-map-edit.component.html&#39;,<br>  styleUrls: [&#39;./role-user-map-edit.component.scss&#39;]<br>})<br>export class RoleUserMapEditComponent implements OnInit {<br>private sub: Subscription; <br>id:string;<br><br>constructor(<br>    private route: ActivatedRoute<br>  ) { }<br><br>ngOnInit(): void {<br>     this.sub = this.route.params.subscribe(params =&gt; {<br>      this.id = params[&#39;userId&#39;];<br>});<br><br> ngOnDestroy(): void {<br>    this.sub.unsubscribe();<br>  }</pre><ul><li>First you will get activatedRoute by instantiating service inside constructor.</li><li>Next you will create a private subscription,Remember you have to unsubscribe it in ngOnDestroy to avoid memory leakage.</li><li>Then you subscribe to your activatedRoute and use it .</li></ul><h3>Using Query Parameters</h3><p>Let’s say you don’t wanna send only userId,You wanna send name and mobileNo as well.While sending multiple parameters you use query parameters.</p><p><strong>How to use it</strong></p><ul><li>You can simply pass queryParams like this <strong>Using Navigator</strong></li></ul><pre>this.router.navigate( [&#39;edit&#39;], { queryParams: { userId: &#39;1101&#39;,mobileNo:931065465}});</pre><p><strong>Using routerLink</strong></p><pre>&lt; a [routerLink]=&quot;[&#39;/edit&#39;]&quot; [queryParams]=&quot;{userId: &#39;1101&#39;,mobileNo:931065465 }&quot; &gt;Edit&lt;/a&gt;</pre><p>Here you will simply send your data through queryParams and it will show like</p><p><a href="http://localhost:4200/userId?userId=1101&amp;mobileNo=9310476536">http://localhost:4200/userId?userId=1101&amp;mobileNo=9310476536</a></p><p>After that you can simply subscribe it like above except the fact you will use queryParams instead of params this time</p><pre>this.sub = this.route.queryParams.subscribe(params =&gt; {<br>this.id = params[&#39;userId&#39;];<br>this.mobileNo=params[&#39;mobileNo&#39;];<br>});</pre><p><strong>One thing if you are routing to another element further and you want queryParams to be preserved ,queryParamHandling will be used for this</strong></p><p><strong>How to use it</strong></p><pre>this.router.navigate( [&#39;details&#39;], { queryParamsHandling:&#39;preserve&#39;});</pre><p>What it will do,let say you need userId in details component, queryParam will be preserved and you can subscribe</p><p><a href="http://localhost:4200/details?userId=1101&amp;mobileNO=931065465">http://localhost:4200/details?userId=1101&amp;mobileNO=931065465</a></p><h3>Using Fragments</h3><p>You can send data using fragments as well</p><p><strong>How to use it</strong></p><ul><li>You can simply pass fragments just like queryParams</li></ul><p><strong>Using Navigator</strong></p><pre>this.router.navigate( [&#39;edit&#39;], {fragment: { userId: &#39;1101&#39;,mobileNo:931065465}});</pre><p><strong>Using routerLink</strong></p><pre>&lt; a [routerLink]=”[&#39;/edit&#39;]” [fragment]=&quot;{userId: &#39;1101&#39;,mobileNo:931065465 }&quot; &gt;Edit&lt;/a&gt;</pre><h3>Static Data</h3><p>You can also send static data directly through route .</p><p><strong>How to use it</strong></p><ul><li>Add data object in your route configuration along with path.</li></ul><pre>{ path: &#39;userId&#39;, component: StaticComponent, data :{ userId:&#39;1101&#39;, mobileNO:931065465}},</pre><ul><li>Now simply subscribe it,just like above we have done for querParams except you will use data this time</li></ul><pre> this.route.data.subscribe(data =&gt; {<br>          this.userInfo=data;<br>      })</pre><h3>Dynamic Data</h3><p>It is possible to send dynamic data as well using state.</p><p><strong>Using routerLink</strong></p><pre>&lt;a [routerLink]=&quot;[&#39;/edit&#39;]&quot; [state]=&quot;{ userId:&#39;1101&#39;, mobileNO:931065465}&quot;&gt;Dynamic Data&lt;/a&gt;</pre><p><strong>Using Navigation</strong></p><pre>this.router.navigate( [&#39;edit&#39;], {state: { userId: &#39;1101&#39;,mobileNo:931065465}});</pre><p><strong>How to subscribe?</strong></p><p>It’s little different from rest,here you have to subscribe in constructor only .It won’t work elsewhere</p><pre>constructor(private router: Router, private activatedRoute: ActivatedRoute)<br> {<br>console.log(this.router.getCurrentNavigation().extras.state);<br>  }</pre><p>Here this.router.getCurrentNavigation().extras.state is getting our dynamic data.</p><p><strong>You can store the state in your local variable and use it anywhere in your program.</strong></p><p><em>I hope it was helpful for you guys .If you liked please share ,like and let me know in comments if any improvement needed. :)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1f72742c2da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hoisting in Javascript]]></title>
            <link>https://medium.com/@deepachaurasia33/hoisting-in-javascript-82ab42ebacc4?source=rss-75811fd81393------2</link>
            <guid isPermaLink="false">https://medium.com/p/82ab42ebacc4</guid>
            <dc:creator><![CDATA[Deepa Chaurasia]]></dc:creator>
            <pubDate>Wed, 06 Jul 2022 18:34:07 GMT</pubDate>
            <atom:updated>2022-07-06T18:36:00.615Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://dev.to/t/javascript">#javascript</a><a href="https://dev.to/t/webdev">#webdev</a><a href="https://dev.to/t/programming">#programming</a><a href="https://dev.to/t/web3">#web3</a></p><p><strong>Hoisting gives higher specificity to javascript declarations.Thus,it makes the computer read and process declaration first before analyzing other code in program</strong></p><p>So hoisting doesn’t mean javascript rearranges or move code above one another.</p><p>Let’s say</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/0*Mz9n642nXfUGTJiK.png" /></figure><p>In this case we are using the name before it’s declaration,however because we are using ‘let’ keyword here it is throwing “Uncaught Reference Error “ to us.</p><p><strong>Variables declared with let and const are hoisted but not initialized with default value</strong></p><p>Accessing let or const before it’s declared gives following error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/0*_a3tqOOHrllk75aq.png" /></figure><p>So one thing to be noticed here is, this error message is telling that variable is initialised somewhere.</p><h3>Variable Hoisting with var</h3><p>When interpreter hoists a variable declared with var ,it initialise it’s value to undefined ,unlike let or const.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/330/0*esmwGaSmvdPsZRX_.png" /></figure><p>Remember console.log(name) outputs undefined, beacause name is hoisted and given a default value (i.e undefined),not because variable is never declared.</p><p>Using undeclared variable will throw the <strong>Reference Error.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/0*bvxe76cnW9ZgAXbU.png" /></figure><p>Now let’s see what happens if we do not declare var what happens</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/0*I_2eRd9xwnH5WFaK.png" /></figure><p><strong>Assigning a variable that’s not defined valid actually.</strong></p><p><strong>Strange Isn’t it??</strong></p><p>Javascript let us access variable before they’re declared.This behaviour is an unusual part of javascript .So it i adviced not to do this.</p><h3>The Temporal Dead Zone</h3><p><strong>So why we get reference error when we try to access let or const before it’s declaration??</strong></p><p><em>This is because of Temporal Dead Zone.</em></p><p>The TDZ starts at the begining of variables enclosing scope and ends when it is declared.</p><p>Accessing variable in TDZ throws an error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/0*aLU_Qycl-RA4-PGn.png" /></figure><p>In case of let or const , it throws Reference Error in TDZ<br>However in case of var it assign it to undefined</p><h3>Functional Hoisting</h3><p>Not only variables but function declarations also get hoisted in javascript.</p><p>Functional hoisting allow us to call function before it is declared or defined.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/0*55j9-8YJyiB3D4qU.png" /></figure><blockquote><strong><em>Only Function declaration are hoisted ,not function expressions.</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/0*WXG8a3QztJDiBw85.png" /></figure><p>It will throw error like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/0*LyXlFE3DUD_fp9Fg.png" /></figure><p>If you use let or const then it will throw error like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/0*J9LlDBjR1GtLa4HU.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/0*C_y4rDa0y0eSyIgc.png" /></figure><p><em>Hope it will help you guys:)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82ab42ebacc4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Destructuring in Javascript]]></title>
            <link>https://medium.com/@deepachaurasia33/destructuring-in-javascript-90cf1f593af1?source=rss-75811fd81393------2</link>
            <guid isPermaLink="false">https://medium.com/p/90cf1f593af1</guid>
            <category><![CDATA[webdesign-and-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Deepa Chaurasia]]></dc:creator>
            <pubDate>Sat, 25 Jun 2022 06:45:06 GMT</pubDate>
            <atom:updated>2022-06-25T06:45:06.501Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Destructutring</strong> is act of unpacking elements in an array or object.It not only allows us to unpack but also manipulate and switch elements when you demand.</p><h3>Destructuring in Arrays</h3><p>Javascript allows you to use rest operator with destructing array to assign the rest of regular array to variable.</p><p><strong>Example of Destructing in Array</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/0*dKTp_BLQxF2gi2QS.png" /></figure><p>As you have noticed [‘devesh’,’ram’] remaining both get strored in var3.</p><p><strong>We use ‘,’ to skip variables at destructing array’s first and second positions ,you just leave it blank.</strong></p><p>Like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/0*OALoSOK-dKel421_.png" /></figure><h3>How default value get assign in Destructing??</h3><p>Let’s see</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/0*0qYd0SnmtpsxfDiT.png" /></figure><p><strong>Here you’ll notice ‘deepa’ and ‘chaurasia’ are default value of ‘firstName’ and ‘lastName’ respectively</strong></p><p><em>Therefore when we have tried to extract first index element it gave ‘chaurasia’ as output, because only zeroth index value exists in [“Deepa Chauraisa”]. It contains only one element .</em></p><h3>Object Destructing in Javascript</h3><p><strong>Object destructing is unique technique that allows you to neatly extract an object’s value to new variables.</strong></p><p>Let’s see with Example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/0*uBBBeW-vNVdh9ES5.png" /></figure><p>here key ‘firstName’ i am talking about in the object on left side.</p><p>So your key will be your object’s key whose value you want to assign in your new variable (i.e your value here)</p><p>Here is the another example of same:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*Ok2-cjWTqIeHJhucqwnuow.png" /></figure><p><strong><em>This was pretty much all about destructing.</em></strong></p><p><em>Thanks for reading,Hope it helped</em><br><em>Please like,save and comment :)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90cf1f593af1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is data Binding in Angular 12]]></title>
            <link>https://medium.com/@deepachaurasia33/what-is-data-binding-in-angular-12-a173778e6c97?source=rss-75811fd81393------2</link>
            <guid isPermaLink="false">https://medium.com/p/a173778e6c97</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Deepa Chaurasia]]></dc:creator>
            <pubDate>Sat, 18 Jun 2022 19:26:52 GMT</pubDate>
            <atom:updated>2022-06-18T19:26:52.818Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Data Binding is communication between typescript code of your component and the template (html) the user see.</strong></p><p>Data Binding === Communication</p><p>We get different ways of communication.</p><p>Let’s say we want to output data from our Typescript code in html template. <strong>We can use String Interpolation for that.</strong></p><p><strong>Syntax for String Interpolation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*3Zx5wEoHoxNdDh29gy72aw.png" /></figure><p>You put it inside double curly braces.</p><p>So in your ts file you have a property name of string type and set to ‘deepa’</p><p><strong>Example of String Interpolation</strong></p><p><strong>In your ts file:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*_bYKBpmJVTA3KwBWxvLTFw.png" /></figure><p><strong>Now in your html you will use it like this:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/0*U18wydiLUSt8mR-8.png" /></figure><p>So it will print ‘My name is Deepa’</p><p>Now suppose you have a button to submit the form or some other task. It must be enabled only if you’re admin. Whether you’re admin or not buisness logic will be handled on your ts file.</p><ul><li>In this case what you can use is <strong>Property Binding</strong></li><li>The native property [disabled] of html file will get bind to a boolean value that will come from ts file .</li></ul><p><strong>Example of Property Binding</strong></p><p><strong>In ts file:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/0*J2GGow3rwx3SlOH5.png" /></figure><p><strong>I have defined a property isAdmin like this and set it to true. Now in my html file</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/0*Lr1NyapS19d8t8zN.png" /></figure><ul><li>Now if user is <strong>not admin</strong> ,then <strong>button will be disabled</strong> otherwise it’s enabled.</li><li>As we are having <strong>isAdmin **set to true so it’s **enabled</strong>.</li></ul><p><strong>Event Binding</strong></p><p>It allows your component to react to user’s actions such as button clicks ,key strokes and many more.</p><p><strong>Like Property Binding use [] Square Brackets</strong></p><p><strong>Similarly Event Binding use () paranthesis.</strong></p><p>Let’s say <strong>If i click on a button ‘Add’ only then data will be binded to html template.</strong></p><p>You can use Event Binding here like this:</p><p><strong>In your ts file</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/0*wFsXMpyWMI_0WcjQ.png" /></figure><p>here you can see,initially name is not set to ‘deepa’ but inside onClick() method we are doing that.</p><p><strong>We’ll call this method by event binding like this:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/0*E_xXd-ndXXb3-Og2.png" /></figure><p>Here in this case,<strong>name will set to ‘deepa’ only after calling the method this is called event binding.</strong></p><p><em>Thanks for reading,Please like share and save if it helped you :)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a173778e6c97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Slice Vs Splice in Javascript]]></title>
            <link>https://medium.com/@deepachaurasia33/slice-vs-splice-in-javascript-c8cce4c1c8bd?source=rss-75811fd81393------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8cce4c1c8bd</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Deepa Chaurasia]]></dc:creator>
            <pubDate>Tue, 14 Jun 2022 17:43:17 GMT</pubDate>
            <atom:updated>2022-06-14T17:58:12.738Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A lot of us often get confused between these methods .We end us googling every time we use them .I will try to make it pretty clear in your head .</em></p><h3>What’s Slice??</h3><p>Slice ==&gt; copying the whole or a part of array.</p><p><strong>Slice()</strong>- The slice() method copies a given part of an array and return that copied part as a new array.</p><p>So let’s say you have a requirement where you don’t want to alter your original array but perform some operations on it.</p><p>You’ll use slice in this case , It will copy the exact array and then you can perform operations on those.</p><ul><li>It doesn’t change original array.</li><li>It copies the whole array or part of it acc to our requirement.</li></ul><p><strong>How to use it??</strong></p><p><strong>Syntax →</strong>array.slice(from,until)</p><p><strong>From</strong>- Slice the array starting from specified index.<br><strong>Until</strong>-Slice the array until another element index.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*PDEtaOz-fADXFRMxRZnEdg.png" /><figcaption>slice use</figcaption></figure><p><strong>You can notice the slice () method doesn’t include the last given element.</strong></p><p>So here we have given index from 1 to 3 ,therefore<br>fruits[1] — -&gt; ‘Orange’ //included<br>fruits[2] — -&gt; ‘Lemon’ //included<br>fruits[3] — -&gt; ‘Apple’ //not included</p><p>Remember the end index elements are not included in slice().</p><p><strong>We can also use it without parameters ,it will copy the whole array</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*TM2dBjZAbo5xfqwQikDlIA.png" /></figure><h3>What’s Splice()?</h3><ul><li>It is used for adding/removing/replacing elements from array.</li><li>It mutate/alter the array unlike slice().</li></ul><p><strong>How to use??</strong></p><p>For removing elements,we need to give index and no of elements to be removed.</p><p><strong>Syntax: </strong>array.splice(index,no of elements)</p><p><strong>Index</strong>-starting point to remove.</p><p><strong>Removing all the elements after index value</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*UEbEY8hFzS_TdrpQSyx_AA.png" /></figure><p>If you pass only one parameter ,it will remove all elements from starting index.</p><p><strong>Inserting elements</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*m9fq8w407tUy-qIZcji1fw.png" /></figure><p>It will remove 0 elements ,that means we are only inserting ‘drum’ at the index 2 .</p><p><em>One thing you’ll notice here that we use ‘0’ as second parameter while inserting elements at certain position.</em></p><p><strong>Removing 0 element</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*lj7H0Nc5z51IULg0AysfBg.png" /></figure><p>It is pretty much like inserting elements I have explained above.</p><p><strong>Removing 1 element</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*yblrgox6CpR2yMxgpYiJFw.png" /></figure><p>Here, you’ll notice notice we have define I want to remove 1(no of elements) from index 3.Therefore myFish[3](i.e ‘mandarin’) got removed.</p><p><strong>Replacing elements</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*ctyHCebcercre84v3voCxQ.png" /></figure><p>Here you can notice at index 2 which is myFish[2](i.e ‘drum’) got removed as we have specified second argument (i.e no of elements as 1) so 1 element on the index one itself got removed.</p><p><strong>Remember We use ‘0’ as second argument if we wanna insert element. We use ‘1&#39; if we want to replace</strong></p><p><em>Thanks for reading ,Please like,share and comment</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8cce4c1c8bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>