<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: michele</title>
    <description>The latest articles on DEV Community by michele (@michelemalagnini).</description>
    <link>https://dev.to/michelemalagnini</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1260667%2F946471e5-15e8-41c3-8c50-10a1cd1b405a.png</url>
      <title>DEV Community: michele</title>
      <link>https://dev.to/michelemalagnini</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/michelemalagnini"/>
    <language>en</language>
    <item>
      <title>My React Journey: Day 3 – Rendering Lists with Angular @for and React .map()</title>
      <dc:creator>michele</dc:creator>
      <pubDate>Sun, 31 Aug 2025 19:08:51 +0000</pubDate>
      <link>https://dev.to/michelemalagnini/my-react-journey-day-3-rendering-lists-with-angular-for-and-react-map-p1n</link>
      <guid>https://dev.to/michelemalagnini/my-react-journey-day-3-rendering-lists-with-angular-for-and-react-map-p1n</guid>
      <description>&lt;p&gt;Hello everybody, welcome back to Day 3 of my React Journey!&lt;br&gt;
Yesterday we rendered a simple header, but today we’re leveling up:&lt;/p&gt;

&lt;p&gt;We’ll take a typed array of shopping items, render it inside our component, and add a delete button with an icon.&lt;br&gt;
This will show how Angular and React approach list rendering — Angular with the new &lt;a class="mentioned-user" href="https://dev.to/for"&gt;@for&lt;/a&gt; syntax, React with the standard .map() method.&lt;/p&gt;

&lt;p&gt;I’ve also updated the CSS styles for the shopping cart, but to keep the code clean we’ll skip them here — you can find the full styles in the repository&lt;br&gt;
.&lt;/p&gt;

&lt;p&gt;Angular 19 Application&lt;/p&gt;

&lt;p&gt;In Angular we start by defining a TypeScript type for our shopping items:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type Item = {
  id: number;
  label: string;
  purchased: boolean;
  higherPriority: boolean;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We store an array of items inside a signal, and render them with Angular’s new control-flow syntax &lt;a class="mentioned-user" href="https://dev.to/for"&gt;@for&lt;/a&gt;.&lt;br&gt;
For the delete button, we add an Angular Material remove icon.&lt;/p&gt;

&lt;p&gt;Code: ShoppingCartComponent&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { matRemove } from '@ng-icons/material-icons/baseline';

type Item = {
  id: number;
  label: string;
  purchased: boolean;
  higherPriority: boolean;
};

@Component({
  selector: 'app-shopping-cart',
  imports: [NgIcon],
  viewProviders: [provideIcons({ matRemove })],
  template: `
    &amp;lt;h1&amp;gt;{{ header() }}&amp;lt;/h1&amp;gt;
    &amp;lt;ul&amp;gt;
      @for (item of items(); track item.id) {
        &amp;lt;div class="list-item"&amp;gt;
          &amp;lt;li&amp;gt;{{ item.id }} - {{ item.label }}&amp;lt;/li&amp;gt;
          &amp;lt;button class="btn btn-cancel" aria-label="Delete"&amp;gt;
            &amp;lt;ng-icon name="matRemove"&amp;gt;&amp;lt;/ng-icon&amp;gt;
          &amp;lt;/button&amp;gt;
        &amp;lt;/div&amp;gt;
      }
    &amp;lt;/ul&amp;gt;
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ShoppingCartComponent {
  header = signal('Shopping List App - Angular 19');
  items = signal&amp;lt;Item[]&amp;gt;([
    { id: 1, label: '10 Apples', purchased: false, higherPriority: false },
    { id: 2, label: '5 Bananas', purchased: false, higherPriority: false },
  ]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Angular key points:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;signal&amp;lt;Item[]&amp;gt;&lt;/code&gt;→ reactive array of items.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@for (item of items(); track item.id)&lt;/code&gt; → Angular’s modern, optimized replacement for *ngFor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;track item.id&lt;/code&gt;ensures stable identity for efficient DOM updates.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ChangeDetectionStrategy.OnPush&lt;/code&gt; makes the component even more performant.&lt;/p&gt;

&lt;p&gt;React&lt;/p&gt;

&lt;p&gt;React follows the same logic, but instead of structural directives, we rely on plain JavaScript array methods.&lt;br&gt;
We’ll define a type Item, create the array, and use .map() to loop through the items.&lt;/p&gt;

&lt;p&gt;Code: ShoppingCartComponent&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Icon } from "@iconify/react";
import "./ShoppingCart.css";

type Item = {
  id: number;
  label: string;
  purchased: boolean;
  higherPriority: boolean;
};

export function ShoppingCart() {
  const header: string = "Shopping List App - React";

  const items: Item[] = [
    { id: 1, label: "10 Apples", purchased: false, higherPriority: false },
    { id: 2, label: "5 Bananas", purchased: false, higherPriority: false },
  ];

  return (
    &amp;lt;&amp;gt;
      &amp;lt;h1&amp;gt;{header}&amp;lt;/h1&amp;gt;
      &amp;lt;ul className="shopping-list"&amp;gt;
        {items.map((item) =&amp;gt; (
          &amp;lt;div key={item.id} className="list-item"&amp;gt;
            &amp;lt;div className="list-item-content"&amp;gt;
              &amp;lt;span className="item-text"&amp;gt;
                {item.id} - {item.label}
              &amp;lt;/span&amp;gt;
            &amp;lt;/div&amp;gt;
            &amp;lt;button className="btn btn-cancel" aria-label="Delete"&amp;gt;
              &amp;lt;Icon icon="ic:baseline-remove" /&amp;gt;
            &amp;lt;/button&amp;gt;
          &amp;lt;/div&amp;gt;
        ))}
      &amp;lt;/ul&amp;gt;
    &amp;lt;/&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;React key points for Angular developers:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;type Item&lt;/code&gt;→ same TypeScript typing as in Angular.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;items.map(...)&lt;/code&gt;→ React’s way of looping over data, equivalent to Angular’s &lt;a class="mentioned-user" href="https://dev.to/for"&gt;@for&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;key={item.id}&lt;/code&gt; → same purpose as track item.id in Angular. It helps React efficiently update the DOM.&lt;/p&gt;

&lt;p&gt;JSX interpolation &lt;code&gt;{}&lt;/code&gt; is the React counterpart of Angular’s &lt;code&gt;{{}}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The styles are placed in ShoppingCart.css — see the repository&lt;br&gt;
 for details.&lt;/p&gt;

&lt;p&gt;Summary&lt;/p&gt;

&lt;p&gt;Day 3 upgrade: from a single header to a typed, rendered list of items.&lt;/p&gt;

&lt;p&gt;Angular: used signals + &lt;a class="mentioned-user" href="https://dev.to/for"&gt;@for&lt;/a&gt; loop with tracking for performance.&lt;/p&gt;

&lt;p&gt;React: used a TypeScript type + .map() to iterate items with keys.&lt;/p&gt;

&lt;p&gt;Both approaches highlight the same principle: data drives the UI.&lt;/p&gt;

&lt;p&gt;Github Repos:&lt;br&gt;
&lt;a href="https://github.com/michelemalagnini/angular-project-example" rel="noopener noreferrer"&gt;https://github.com/michelemalagnini/angular-project-example&lt;br&gt;
&lt;/a&gt;&lt;a href="https://github.com/michelemalagnini/react-fundamental" rel="noopener noreferrer"&gt;https://github.com/michelemalagnini/react-fundamental&lt;/a&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>react</category>
      <category>typescript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>My React Journey: Day 2- Create a component and use expression in template</title>
      <dc:creator>michele</dc:creator>
      <pubDate>Sun, 31 Aug 2025 09:34:02 +0000</pubDate>
      <link>https://dev.to/michelemalagnini/my-react-journey-day-2-create-a-component-and-use-expression-in-template-55oo</link>
      <guid>https://dev.to/michelemalagnini/my-react-journey-day-2-create-a-component-and-use-expression-in-template-55oo</guid>
      <description>&lt;p&gt;Hello everybody, this is my second React journey (Day 2).&lt;br&gt;
Today we will create a component both in Angular and React, and we’ll see how to interpolate an expression (a variable) inside the template.&lt;/p&gt;
&lt;h2&gt;
  
  
  Angular 19 application
&lt;/h2&gt;

&lt;p&gt;In Angular we can use angular cli command to generate a component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng g c shopping-cart/shoppingCart --flat

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

&lt;/div&gt;



&lt;p&gt;Then delete shopping-cart.component.html, shopping-cart.component.scss, and shopping-cart.component.spect.ts.&lt;/p&gt;

&lt;p&gt;We will use a inline templat and we will add:&lt;/p&gt;

&lt;p&gt;1)ChangeDetectionStrategy.OnPush&lt;/p&gt;

&lt;p&gt;This is a performance optimization.&lt;br&gt;
By default, Angular checks every component whenever something changes. With OnPush, Angular only checks the component when an input changes or when an event inside it is triggered.&lt;br&gt;
This reduces unnecessary checks and speeds up large apps.&lt;/p&gt;

&lt;p&gt;2)header = signal('Shopping List App - Angular');&lt;/p&gt;

&lt;p&gt;Signals are Angular’s new reactivity model. A signal holds a value and notifies Angular whenever it changes. Any template bound to this signal will automatically update.&lt;br&gt;
Here, the signal holds the string "Shopping List App - Angular".&lt;/p&gt;

&lt;p&gt;This is the code component file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ChangeDetectionStrategy, Component, signal } from '@angular/core';

@Component({
 selector: 'app-shopping-cart',
 imports: [],
 template: `
   &amp;lt;h1&amp;gt;{{ header() }}&amp;lt;/h1&amp;gt;
 `,
 changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ShoppingCartComponent {
   header = signal('Shopping List App - Angular');
}

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

&lt;/div&gt;



&lt;p&gt;Finally, add the component to app.component.ts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ShoppingCartComponent } from './shopping-cart/shopping-cart.component';

@Component({
 selector: 'app-root',
 imports: [ShoppingCartComponent],
 template: '&amp;lt;app-shopping-cart /&amp;gt;',
 changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the app shows the header inside an &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  React
&lt;/h2&gt;

&lt;p&gt;Unlike Angular, React doesn’t have a CLI that auto-generates components with decorators and separate files for HTML/CSS.&lt;br&gt;
In React with TypeScript, every component is simply a TypeScript function that returns JSX.&lt;br&gt;
The file extension is .tsx (TypeScript + JSX), which allows us to write both logic and template in the same file.&lt;/p&gt;

&lt;p&gt;Step 1 – Creating the component&lt;/p&gt;

&lt;p&gt;Inside the src/ folder, create a components/ directory.&lt;/p&gt;

&lt;p&gt;Inside it, create the file ShoppingCartComponent.tsx.&lt;/p&gt;

&lt;p&gt;Code: ShoppingCartComponent.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export function ShoppingCart() {
  const header = "Shopping Cart";
  return (
    &amp;lt;&amp;gt;
      &amp;lt;h1&amp;gt;{header}&amp;lt;/h1&amp;gt;
    &amp;lt;/&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation for Angular developers:&lt;/p&gt;

&lt;p&gt;const header: string → this is just a plain TypeScript variable. No signal() or @Input decorator needed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;h1&amp;gt;{header}&amp;lt;/h1&amp;gt;&lt;/code&gt; → the curly braces {} in JSX are the React equivalent of Angular’s {{ header() }} syntax for interpolation.&lt;/p&gt;

&lt;p&gt;JSX looks like HTML, but it’s actually TypeScript/JavaScript that compiles down to React function calls.&lt;/p&gt;

&lt;p&gt;Step 2 – Using the component in the root&lt;/p&gt;

&lt;p&gt;In App.tsx, import the component and render it inside the template:&lt;/p&gt;

&lt;p&gt;Code: App.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ShoppingCart } from "./components/ShoppingCartComponent";

function App() {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;ShoppingCart /&amp;gt;
    &amp;lt;/&amp;gt;
  );
}

export default App;

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

&lt;/div&gt;



&lt;p&gt;Angular → React analogy:&lt;/p&gt;

&lt;p&gt;App.tsx = Angular’s AppComponent.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;ShoppingCart /&amp;gt;&lt;/code&gt; = Angular’s &lt;code&gt;&amp;lt;app-shopping-cart /&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;No imports array or NgModule setup is required. You just import the function and use it as a JSX tag.&lt;/p&gt;

&lt;p&gt;Summary&lt;/p&gt;

&lt;p&gt;In Angular, we created a component with signals and ChangeDetectionStrategy.OnPush.&lt;/p&gt;

&lt;p&gt;In React + TypeScript, we built a function component in .tsx that returns JSX and interpolates variables using {...}.&lt;/p&gt;

&lt;p&gt;The ShoppingCart component was then imported and rendered inside App.tsx, just like adding a child component to Angular’s AppComponent.&lt;/p&gt;

&lt;p&gt;Github Repos:&lt;br&gt;
&lt;a href="https://github.com/michelemalagnini/angular-project-example" rel="noopener noreferrer"&gt;https://github.com/michelemalagnini/angular-project-example&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/michelemalagnini/react-fundamental" rel="noopener noreferrer"&gt;https://github.com/michelemalagnini/react-fundamental&lt;/a&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>react</category>
      <category>typescript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>My React Journey: Day 1- Create a new project, add dependencies, and global CSS styles</title>
      <dc:creator>michele</dc:creator>
      <pubDate>Sat, 30 Aug 2025 10:05:43 +0000</pubDate>
      <link>https://dev.to/michelemalagnini/my-react-journey-day-1-create-a-new-project-add-dependencies-and-global-css-styles-4cfh</link>
      <guid>https://dev.to/michelemalagnini/my-react-journey-day-1-create-a-new-project-add-dependencies-and-global-css-styles-4cfh</guid>
      <description>&lt;p&gt;Hello everyone&lt;/p&gt;

&lt;p&gt;I'm Michele Malagnini, an Angular developer. For my next article, I want to help fellow Angular developers learn React. To do this, I'm drawing inspiration from a cool series of articles where a developer &lt;a href="https://dev.to/railsstudent/day-1-create-a-new-projects-dependencies-and-global-css-styles-3b5j"&gt;Connie Leung&lt;/a&gt; built a basic app in Vue and then ported it to Svelte and Angular. I'm going to follow a similar path, taking his original Angular application and rebuilding it from the ground up in React, all while using TypeScript.&lt;/p&gt;

&lt;p&gt;We are going to do a simple CRUD application a shopping cart that adds and delets items from it&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;1. Create a new project *&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Angular 19 application
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng new angular-project-example
select css or what you want for css style
do not use ssr and ssg Type no

cd angular-project-example
npm i
ng serve
go to localhost://4200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  React
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vite@4         # install version Vite 4.x 
name: react-project-example
react -&amp;gt; typescript

cd react-project-example
npm i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;2. Install Icon library *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Like a Connie Leung article I would like to use icons to make the examples more creative :-P. I installed Iconify for react and ng-icons for Angular.&lt;/p&gt;

&lt;h2&gt;
  
  
  Angular 19 application
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save-exact @ng-icons/core @ng-icons/materialicons
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  React
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i @iconify/react
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;3. edit global stylesheet *&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Angular 19 application
&lt;/h2&gt;

&lt;p&gt;Angular 19 application&lt;br&gt;
Update the global styles in styles.css&lt;br&gt;
copy the file &lt;a href="https://github.com/michelemalagnini/angular-project-example/blob/master/src/styles.css" rel="noopener noreferrer"&gt;src/styles.css&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  React
&lt;/h2&gt;

&lt;p&gt;create the file src/styles/global.css&lt;br&gt;
copy this file &lt;a href="https://github.com/michelemalagnini/react-fundamental/blob/master/src/styles/global.css" rel="noopener noreferrer"&gt;src/styles/global.css&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Import it once in the app's bootstrap.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// src/main.tsx
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'

// impor here the global stylesheet
import './styles/global.css'

ReactDOM.createRoot(document.getElementById('root')!).render(&amp;lt;App /&amp;gt;)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Resources&lt;br&gt;
Github Repos:&lt;br&gt;
&lt;a href="https://github.com/michelemalagnini/angular-project-example" rel="noopener noreferrer"&gt;https://github.com/michelemalagnini/angular-project-example&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/michelemalagnini/react-fundamental" rel="noopener noreferrer"&gt;https://github.com/michelemalagnini/react-fundamental&lt;/a&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>react</category>
      <category>typescript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Hot vs Cold Observables in Angular: Understanding the Difference</title>
      <dc:creator>michele</dc:creator>
      <pubDate>Mon, 14 Oct 2024 09:41:42 +0000</pubDate>
      <link>https://dev.to/michelemalagnini/hot-vs-cold-observables-in-angular-understanding-the-difference-2f1l</link>
      <guid>https://dev.to/michelemalagnini/hot-vs-cold-observables-in-angular-understanding-the-difference-2f1l</guid>
      <description>&lt;p&gt;If you've ever wondered what makes RxJS Observables so powerful in Angular, and more importantly, what makes some of them "hot" or "cold," then you're in the right place. Today, we'll break down the basics of Observables, how they fit into the Angular ecosystem, and take a deep dive into the differences between hot and cold Observables.&lt;/p&gt;

&lt;p&gt;What Are Observables?&lt;/p&gt;

&lt;p&gt;First things first: Observables are core components in RxJS (Reactive Extensions for JavaScript), which Angular uses heavily for handling asynchronous events like HTTP requests, user input, or even WebSocket data. An Observable is a stream of data that can be processed asynchronously—think of it as a river carrying data packets instead of water. You subscribe to the Observable to start receiving data, much like you would scoop up water from a river when you're ready.&lt;/p&gt;

&lt;p&gt;In Angular, Observables are used extensively, particularly with services like HttpClient for making API calls, as well as in reactive forms or event handling to allow seamless and powerful data flow management.&lt;/p&gt;

&lt;p&gt;The Real Question: Hot vs Cold Observables&lt;/p&gt;

&lt;p&gt;The real magic starts when you understand the difference between hot and cold Observables. This distinction is at the heart of RxJS and is key to knowing how and when to use them in your Angular applications.&lt;/p&gt;

&lt;p&gt;Cold Observables&lt;/p&gt;

&lt;p&gt;Cold Observables are like a personal concert—they don't start playing until you arrive and buy a ticket. In other words, a cold Observable only starts emitting values when you subscribe to it. If two people subscribe at different times, they each get their own independent stream of values.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

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

const coldObservable = new Observable(observer =&amp;gt; {
  observer.next('Hello');
  setTimeout(() =&amp;gt; observer.next('World!'), 1000);
});

// Subscriber 1
coldObservable.subscribe(value =&amp;gt; console.log('Subscriber 1:', value));

// Subscriber 2 (with delay)
setTimeout(() =&amp;gt; {
  coldObservable.subscribe(value =&amp;gt; console.log('Subscriber 2:', value));
}, 500);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, Subscriber 2 will receive "Hello" and "World!" with a delay. Each subscriber essentially gets a unique concert.&lt;/p&gt;

&lt;p&gt;Hot Observables&lt;/p&gt;

&lt;p&gt;Hot Observables, on the other hand, are like a radio broadcast—it's playing whether you're listening or not. If you tune in late, you'll miss whatever has already been broadcast. They start emitting values as soon as they're created, regardless of whether anyone is subscribed.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

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

const hotObservable = new Subject();

hotObservable.next('Broadcast started');

// Subscriber 1 (gets everything)
hotObservable.subscribe(value =&amp;gt; console.log('Subscriber 1:', value));

hotObservable.next('Live update 1');

// Subscriber 2 (misses the first value)
hotObservable.subscribe(value =&amp;gt; console.log('Subscriber 2:', value));

hotObservable.next('Live update 2');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Subscriber 1 catches everything, but Subscriber 2 misses the initial broadcast and only catches updates starting from the point it subscribes.&lt;/p&gt;

&lt;p&gt;When to Use Which?&lt;/p&gt;

&lt;p&gt;Cold Observables are great for tasks like HTTP requests, where each subscriber expects a unique response—like fetching user data from an API. Every time you subscribe, you want a fresh stream that starts from the beginning.&lt;/p&gt;

&lt;p&gt;Hot Observables are ideal for scenarios like live updates, shared streams, or user interactions. Think about a WebSocket connection or a user action that multiple parts of your application are listening to simultaneously.&lt;/p&gt;

&lt;p&gt;Bringing It All Together in Angular&lt;/p&gt;

&lt;p&gt;In Angular, knowing whether you're dealing with a hot or cold Observable is crucial for understanding the flow of data. The HttpClient service, for example, returns cold Observables, meaning every time you subscribe, the HTTP request is sent again.&lt;/p&gt;

&lt;p&gt;On the other hand, you can turn an Observable hot using subjects like ReplaySubject or BehaviorSubject to multicast data. This way, multiple components can share the same data stream without re-triggering events.&lt;/p&gt;

&lt;p&gt;Wrap-Up&lt;/p&gt;

&lt;p&gt;Hot and cold Observables may seem like a tricky concept at first, but once you get the hang of it, you'll find they add incredible flexibility to your applications. Remember—cold Observables are unique streams for every subscriber, while hot Observables are shared experiences that emit continuously. Mastering these will make you a pro at handling async operations and data flow in Angular!&lt;/p&gt;

&lt;p&gt;Happy coding, and keep those Observables flowing!&lt;/p&gt;

</description>
      <category>angular</category>
      <category>observable</category>
      <category>rxjs</category>
    </item>
    <item>
      <title>Unlocking Complex Structures in JavaScript: A Guide for Front-End Developers</title>
      <dc:creator>michele</dc:creator>
      <pubDate>Sun, 06 Oct 2024 14:53:09 +0000</pubDate>
      <link>https://dev.to/michelemalagnini/unlocking-complex-structures-in-javascript-a-guide-for-front-end-developers-5aaf</link>
      <guid>https://dev.to/michelemalagnini/unlocking-complex-structures-in-javascript-a-guide-for-front-end-developers-5aaf</guid>
      <description>&lt;p&gt;Hey there, fellow devs! If you've ever found yourself tangled in the web of JavaScript arrays and objects, you're not alone. Navigating these complex data structures is key to writing efficient, clean code. So let's break it down together, step by step, and keep things fun and relatable.&lt;/p&gt;

&lt;p&gt;Getting Started: Simple Examples&lt;/p&gt;

&lt;p&gt;Arrays&lt;/p&gt;

&lt;p&gt;Think of an array as a simple list where you can keep a bunch of stuff in one place. Like this:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let fruits = ['Apple', 'Banana', 'Cherry'];

// Accessing elements
console.log(fruits[0]); // Output: Apple
console.log(fruits[2]); // Output: Cherry
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Easy, right? You just grab what you need by its position in the list.&lt;/p&gt;

&lt;p&gt;Objects&lt;/p&gt;

&lt;p&gt;Now, objects are like a toolbox with labeled drawers. Each drawer has a name and some value inside. Check it out:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let person = {
    name: 'John',
    age: 30,
    city: 'New York'
};

// Accessing properties
console.log(person.name); // Output: John
console.log(person.city); // Output: New York
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, if you need John’s age or where he lives, you just call it by name. Super handy!&lt;/p&gt;

&lt;p&gt;Going Deeper: Advanced Examples&lt;/p&gt;

&lt;p&gt;Nested Arrays&lt;/p&gt;

&lt;p&gt;Alright, sometimes you’ve got arrays within arrays (kind of like an onion with layers). Here’s how you work with those layers:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let numbers = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];

// Accessing nested elements
console.log(numbers[1][2]); // Output: 6
console.log(numbers[2][0]); // Output: 7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just think of it like coordinates on a map. The first number is the main list, and the second number gets you the specific item.&lt;/p&gt;

&lt;p&gt;Nested Objects&lt;/p&gt;

&lt;p&gt;Objects can get pretty deep too—like a box inside another box. Here’s an example:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let car = {
    brand: 'Toyota',
    model: 'Corolla',
    specs: {
        engine: '1.8L',
        horsepower: 132
    }
};

// Accessing nested properties
console.log(car.specs.engine); // Output: 1.8L
console.log(car.specs.horsepower); // Output: 132
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It’s like looking inside the specs drawer of the car toolbox to find out what’s under the hood.&lt;/p&gt;

&lt;h4&gt;
  
  
  Complex Structures
&lt;/h4&gt;

&lt;p&gt;Let's take it up a notch with more intricate structures.&lt;/p&gt;

&lt;p&gt;Taking It Up a Notch: Complex Structures&lt;/p&gt;

&lt;p&gt;Arrays of Objects&lt;/p&gt;

&lt;p&gt;In the real world, you'll often deal with arrays packed full of objects. Picture a class roster full of students:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let students = [
    {name: 'Alice', grade: 'A'},
    {name: 'Bob', grade: 'B'},
    {name: 'Charlie', grade: 'C'}
];

// Accessing elements in an array of objects
console.log(students[1].name); // Output: Bob
console.log(students[2].grade); // Output: C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, each student is an object, and they’re all in one big array. Just pick the student you want and grab their info!&lt;/p&gt;

&lt;p&gt;Objects with Arrays&lt;/p&gt;

&lt;p&gt;And it works the other way too—objects that have arrays inside. It’s great for keeping lists organized:&lt;/p&gt;

&lt;p&gt;javascript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let library = {
    name: 'Central Library',
    books: ['JavaScript: The Good Parts', 'Eloquent JavaScript', 'You Don’t Know JS']
};

// Accessing array elements within an object
console.log(library.books[0]); // Output: JavaScript: The Good Parts
console.log(library.books[2]); // Output: You Don’t Know JS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of the library object as the building, and inside it, there’s a shelf full of books you can easily reference.&lt;/p&gt;

&lt;p&gt;Wrapping Up&lt;/p&gt;

&lt;p&gt;Getting comfortable with these complex structures is a game-changer for front-end development. When you know how to navigate through nested arrays and objects, you’re way better equipped to handle data like a pro. Just keep practicing, and soon enough, it’ll be second nature—like riding a bike, but for JavaScript!&lt;/p&gt;

&lt;p&gt;Happy coding, and see you in the next guide!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
