<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Akande Olalekan Toheeb - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Akande Olalekan Toheeb - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Tue, 05 May 2026 19:57:44 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/MuhToyyib/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Start Learning TypeScript – A Beginner's Guide ]]>
                </title>
                <description>
                    <![CDATA[ JavaScript is the most widely-used programming language for web development. But it lacks type-checking support, which is an essential feature of modern programming languages. JavaScript was originally designed as a simple scripting language. Its loo... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/start-learning-typescript-beginners-guide/</link>
                <guid isPermaLink="false">6792ea9437616d62ca07fe03</guid>
                
                    <category>
                        <![CDATA[ TypeScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Beginner Developers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Programming Blogs ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Technical writing  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tutorial ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Akande Olalekan Toheeb ]]>
                </dc:creator>
                <pubDate>Fri, 24 Jan 2025 01:19:16 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1737681395105/19aeca8f-e763-4833-9ac3-5c4db7d12fe7.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>JavaScript is the most widely-used programming language for web development. But it lacks type-checking support, which is an essential feature of modern programming languages.</p>
<p>JavaScript was originally designed as a simple scripting language. Its loose nature and absence of crucial <strong>Object-Oriented Programming (OOP)</strong> features pose certain challenges for developers:</p>
<ol>
<li><p>Limited documentation and auto-completion.</p>
</li>
<li><p>Inability to utilise OOP concepts.</p>
</li>
<li><p>Lack of type safety, leading to runtime errors.</p>
</li>
<li><p>Challenges in refactoring and maintenance.</p>
</li>
<li><p>Absence of interfaces and integration points.</p>
</li>
</ol>
<p>TypeScript solves these problems. It was built to make JavaScript a more perfect modern programming language. It helps improve the developer experience, offers many useful features, and improves interoperability.</p>
<p>This article dives into TypeScript basics. I’ll teach you how to install TS and set up a project. Then we’ll cover some important fundamentals. You’ll also learn how TypeScript compiles into JavaScript, making it compatible with browsers and Node.js environments.</p>
<h3 id="heading-what-well-coverheading-what-well-cover"><a class="post-section-overview" href="#heading-what-well-cover">What we’ll cover:</a></h3>
<ul>
<li><p><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-getting-started-how-to-install-typescript">Getting Started – How to Install TypeScript</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-organize-your-typescript-projects">How to Organize Your TypeScript Projects</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-typing-works-in-typescript">How Typing Works in TypeScript</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-typing-techniques">Typing Techniques</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-static-vs-dynamic-typing-in-typescript">Static vs. Dynamic Typing in TypeScript</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-type-inference-and-union-types">Type Inference and Union Types</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-handle-objects-arrays-and-function-types-in-typescript">How to Handle Objects, Arrays, and Function Types in TypeScript</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-object-types-in-typescript">Object Types in TypeScript</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-array-types-in-typescript">Array Types in TypeScript</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-use-arrays-in-typescript">How to Use Arrays in TypeScript</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-function-types-in-typescript">Function Types in TypeScript</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-create-custom-types-in-typescript">How to Create Custom Types in TypeScript</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-the-type-keyword">The Type Keyword</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-typescript-interfaces">TypeScript Interfaces</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-when-to-use-interfaces">When to Use Interfaces</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-generics-and-literal-types">Generics and Literal Types</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-merge-types-in-typescript">How to Merge Types in TypeScript</a></p>
<ul>
<li><a class="post-section-overview" href="#heading-when-to-use-each-approach">When to Use Each Approach</a></li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-bundling-and-transformations-in-typescript">Bundling and Transformations in TypeScript</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-building-better-code-with-typescript">Building Better Code with TypeScript</a></p>
</li>
</ul>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before diving into TypeScript, it's important to have a foundational understanding of certain concepts to ensure a smoother learning journey. While TypeScript enhances JavaScript with static typing and other powerful features, it builds on core JavaScript principles. Here's what you should know:</p>
<h4 id="heading-1-javascript-fundamentals"><strong>1. JavaScript Fundamentals</strong></h4>
<p>TypeScript is a superset of JavaScript, meaning it extends JavaScript's capabilities. To effectively learn TypeScript, you should first have a solid grasp of JavaScript basics, including:</p>
<ul>
<li><p><strong>Syntax and data types:</strong> Understand how to declare variables (<code>let</code>, <code>const</code>, and <code>var</code>), work with primitive types (strings, numbers, booleans), and manage arrays and objects.</p>
</li>
<li><p><strong>Control flow:</strong> Be familiar with loops (<code>for</code>, <code>while</code>), conditionals (<code>if-else</code>, <code>switch</code>), and how they control program execution.</p>
</li>
<li><p><strong>Functions:</strong> Know how to define and invoke functions, work with parameters, return values, and understand concepts like arrow functions and closures.</p>
</li>
<li><p><strong>Object-Oriented Programming (OOP):</strong> Learn about creating and working with objects, classes, and inheritance. TypeScript's class-based features build heavily on JavaScript's OOP model.</p>
</li>
<li><p><strong>Error handling:</strong> Understand how to use <code>try-catch</code> blocks to handle runtime errors.</p>
</li>
</ul>
<h4 id="heading-2-basic-html-and-css"><strong>2. Basic HTML and CSS</strong></h4>
<p>Although TypeScript is a language used primarily with JavaScript, having a basic understanding of HTML and CSS is helpful, especially for front-end developers. This is because most TypeScript projects involve creating or working with web applications</p>
<ul>
<li><p><strong>HTML:</strong> Understand how to structure web pages using tags, attributes, and elements.</p>
</li>
<li><p><strong>CSS:</strong> Learn how to style elements using selectors, properties, and values. Familiarity with CSS frameworks like Bootstrap is a bonus.</p>
</li>
</ul>
<h4 id="heading-3-familiarity-with-development-tools"><strong>3. Familiarity with Development Tools</strong></h4>
<ul>
<li><p><strong>A code editor</strong> like Visual Studio Code, which has excellent TypeScript support and extensions.</p>
</li>
<li><p><strong>Node.js and npm:</strong> Understand how to set up a development environment, run JavaScript outside the browser, and use npm (Node Package Manager) to install dependencies.</p>
</li>
<li><p><strong>Version control (Git):</strong> Learn the basics of Git to track changes and collaborate effectively on TypeScript projects.</p>
</li>
</ul>
<h2 id="heading-getting-started-how-to-install-typescript">Getting Started – How to Install TypeScript</h2>
<p>To get started working with TypeScript you’ll need to install it. It’s not a complicated process. With TypeScript installed, you can leverage its power to create high-quality solutions.</p>
<p>You can install TS in two ways:</p>
<ol>
<li><strong>Global Installation</strong>: enables you to access the compiler from any directory on your machine. To install TypeScript globally, execute the following command:</li>
</ol>
<pre><code class="lang-bash">npm install -g typescript
</code></pre>
<p>This command leverages the Node.js package manager, <code>npm</code>. It installs TypeScript globally, making the command available in the command line.</p>
<ol start="2">
<li><strong>Local Installation</strong>: in this case, TypeScript is installed only within a specific project. This method ensures version compatibility and consistency across team members. To install TypeScript locally, execute the following command:</li>
</ol>
<pre><code class="lang-bash">npm install typescript --save-dev
</code></pre>
<p>Different from global installation, this command installs TypeScript as a development dependency. The <code>tsc</code> command is only available for project-specific usage, that is the specific project where you run the command.</p>
<p><strong>Can you seamlessly install TypeScript now? I hope so!</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1737293526617/2f630f4c-c74f-4525-a291-9febf06d8d8b.gif" alt="2f630f4c-c74f-4525-a291-9febf06d8d8b" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h2 id="heading-how-to-organize-your-typescript-projects">How to Organize Your TypeScript Projects</h2>
<p>Organizing a TypeScript project involves structuring its files with meaningful names and directories, separating concerns, and using modules for encapsulation and reusability.</p>
<p>The <code>.ts</code> extension denotes typeScript files and contains code that converts into JavaScript for execution.</p>
<p>TypeScript also supports <code>.d.ts</code> files, also known as type definition files. These files offer type information about external JavaScript libraries or modules, aiding in better type-checking and code completion as well as improving development efficiency. Below is an example of a good TS project structure:</p>
<pre><code class="lang-plaintext">my-ts-project/
├── src/ 
│   ├── components/ 
│   │   ├── Button.tsx
│   │   ├── Input.tsx
│   │   └── Modal.tsx
│   ├── services/ 
│   │   ├── api.ts
│   │   └── authService.ts
│   ├── utils/ 
│   │   ├── helpers.ts 
│   │   └── validators.ts
│   ├── models/ 
│   │   ├── User.ts
│   │   └── Product.ts
│   ├── index.tsx 
│   └── styles/ 
│       ├── global.css
│       └── theme.css
├── public/ 
│   ├── index.html
│   └── assets/ 
│       ├── images/
│       └── fonts/
├── tsconfig.json
└── package.json
</code></pre>
<p>Let’s understand what’s going on here:</p>
<ol>
<li><p><code>src/</code>: This directory houses all the source code for the project.</p>
<ul>
<li><p><code>components/</code>: Contains reusable UI components (for example, <code>Button</code>, <code>Input</code>, <code>Modal</code>). Using <code>.tsx</code> (TypeScript JSX) allows you to write JSX with type safety.</p>
</li>
<li><p><code>services/</code>: Holds services that interact with external APIs or handle application logic (for example, <code>api.ts</code> for API calls, <code>authService.ts</code> for authentication).</p>
</li>
<li><p><code>utils/</code>: Contains helper functions and utility classes for common tasks (for example, <code>helpers.ts</code> for date formatting, <code>validators.ts</code> for input validation).</p>
</li>
<li><p><code>models/</code>: Defines TypeScript interfaces or classes to represent data structures (for example, <code>User.ts</code>, <code>Product.ts</code>).</p>
</li>
<li><p><code>index.tsx</code>: The main entry point of the application.</p>
</li>
<li><p><code>styles/</code>: Contains CSS or other styling files.</p>
</li>
</ul>
</li>
<li><p><code>public/</code>: This directory contains static assets that are not processed by TypeScript (for example, HTML, images, fonts).</p>
</li>
<li><p><code>tsconfig.json</code>: The TypeScript configuration file, specifying compiler options.</p>
</li>
<li><p><code>package.json</code>: The project's manifest file, listing dependencies, scripts, and other project metadata.</p>
</li>
</ol>
<p>Just a quick note about naming conventions so you understand them here:</p>
<ul>
<li><p>Use PascalCase for class names (for example, <code>User</code>, <code>Product</code>).</p>
</li>
<li><p>Use camelCase for function names and variable names (for example, <code>getUser</code>, <code>firstName</code>).</p>
</li>
<li><p>Use meaningful and descriptive names for files and directories.</p>
</li>
</ul>
<p>This structure promotes modularity, reusability, and better organization, making your TypeScript projects easier to maintain and scale.</p>
<p>Properly organizing your TS projects enhances code maintainability, readability, and collaboration in TypeScript development workflows.</p>
<h2 id="heading-how-typing-works-in-typescript">How Typing Works in TypeScript</h2>
<p>Like any other typed programming language, TypeScript relies on type definitions, generally called <strong>Typing</strong>.</p>
<p>Typing is a term used in programming to define data types for variables, method parameters, and return values within the code.</p>
<p>Typing allows you to catch errors quickly and early in development, a superpower that helps maintain better code quality.</p>
<p>To specify a type in TypeScript, put a colon( <code>:</code>) and the desired data type after your variable name. Here’s an example:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">let</span> age: <span class="hljs-built_in">number</span> = <span class="hljs-number">2</span>;
</code></pre>
<p>The above variable is declared with the <code>number</code> type. In TypeScript, this means it can store numbers only and nothing else.</p>
<h3 id="heading-typing-techniques">Typing Techniques</h3>
<p>In TypeScript, data can be typed in two main ways:</p>
<ol>
<li><strong>Static Typing</strong>: Static typing refers to explicitly specifying the data type of variables and other entities in the code during development. The TypeScript compiler enforces these type definitions, helping to catch type-related errors early. For example:</li>
</ol>
<pre><code class="lang-typescript"><span class="hljs-keyword">let</span> age: <span class="hljs-built_in">number</span> = <span class="hljs-number">25</span>;
</code></pre>
<p>Here, the variable <code>age</code> is explicitly declared to have the <code>number</code> type. This ensures that only numeric values can be assigned to it, reducing the risk of runtime errors.</p>
<ol start="2">
<li><strong>Dynamic Typing</strong>: Dynamic typing in TypeScript refers to scenarios where the type of a variable is determined at runtime. This can occur when variables are assigned the <code>any</code> type, which allows them to hold values of any type. TypeScript does not perform type-checking on operations involving variables with the <code>any</code> type.</li>
</ol>
<pre><code class="lang-typescript"><span class="hljs-keyword">let</span> value: <span class="hljs-built_in">any</span>;
value = <span class="hljs-number">25</span>; <span class="hljs-comment">// Number</span>
value = <span class="hljs-string">"Hello"</span>; <span class="hljs-comment">// String</span>
</code></pre>
<p>While TypeScript is primarily a statically typed language, dynamic typing can still be useful in specific cases, such as:</p>
<ul>
<li><p>Working with third-party libraries that lack type definitions.</p>
</li>
<li><p>Interfacing with dynamically structured data (for example, JSON responses from APIs with unknown structures).</p>
</li>
<li><p>Rapid prototyping or when type information is unavailable during the initial development phase.</p>
</li>
</ul>
<h3 id="heading-static-vs-dynamic-typing-in-typescript">Static vs. Dynamic Typing in TypeScript</h3>
<p>Static typing is significantly more common in TypeScript, as it is one of the core features that sets TypeScript apart from JavaScript. By enforcing strict type checks, static typing enhances code maintainability, reduces bugs, and improves developer productivity.</p>
<p>Dynamic typing is typically reserved for cases where flexibility is required or when dealing with data whose structure cannot be determined in advance. Just keep in mind that relying heavily on dynamic typing (for example, overusing the <code>any</code> type) is generally discouraged, as it undermines the benefits of TypeScript's static typing system.</p>
<p>So while dynamic typing has its place in certain edge cases, static typing is the preferred and more commonly used approach in TypeScript development.</p>
<h3 id="heading-type-inference-and-union-types">Type Inference and Union Types</h3>
<h4 id="heading-type-inference"><strong>Type Inference</strong></h4>
<p>Type inference is a powerful TypeScript feature that allows the compiler to automatically deduce the type of a variable based on the value assigned to it during initialization. In simpler terms, TypeScript looks at the value you assign to a variable and decides what type it should be, even if you don’t explicitly declare the type.</p>
<p>For example:</p>
<pre><code class="lang-typescript">typescriptCopyEditlet age = <span class="hljs-number">25</span>; <span class="hljs-comment">// TypeScript infers that 'age' is of type 'number'</span>
age = <span class="hljs-string">"hello"</span>; <span class="hljs-comment">// Error: Type 'string' is not assignable to type 'number'</span>
</code></pre>
<p>In this example, the <code>age</code> variable is automatically inferred as a <code>number</code> because of its initial value, <code>25</code>. Any attempt to reassign <code>age</code> to a value of a different type (like a string) will result in a type error.</p>
<p>Type inference is particularly useful because it reduces the need for explicit type annotations, making your code cleaner and more readable. However, it still provides the safety and reliability of TypeScript's type-checking.</p>
<h5 id="heading-when-to-use-type-inference">When to use type inference:</h5>
<ul>
<li><p><strong>Simple assignments</strong>: Use type inference for straightforward assignments where the type is obvious from the value.</p>
</li>
<li><p><strong>Default values</strong>: When providing default values for variables or function parameters, type inference ensures the correct type is applied without requiring manual annotations.</p>
</li>
<li><p><strong>Rapid prototyping</strong>: During early stages of development, type inference can reduce boilerplate code while still enforcing type safety.</p>
</li>
</ul>
<h4 id="heading-union-types"><strong>Union Types</strong></h4>
<p>Union types allow a variable to hold values of multiple types. They are defined by placing a pipe (<code>|</code>) between the types. This feature is particularly useful when a variable may legitimately have more than one type during its lifecycle.</p>
<p>For example:</p>
<pre><code class="lang-typescript">typescriptCopyEditlet numOrString: <span class="hljs-built_in">number</span> | <span class="hljs-built_in">string</span>; <span class="hljs-comment">// 'numOrString' can hold either a number or a string</span>
numOrString = <span class="hljs-number">25</span>; <span class="hljs-comment">// Valid</span>
numOrString = <span class="hljs-string">"hello"</span>; <span class="hljs-comment">// Valid</span>
numOrString = <span class="hljs-literal">true</span>; <span class="hljs-comment">// Error: Type 'boolean' is not assignable to type 'number | string'</span>
</code></pre>
<p>You can even define union types with more than two possible types:</p>
<pre><code class="lang-typescript">typescriptCopyEditlet multiType: <span class="hljs-built_in">number</span> | <span class="hljs-built_in">string</span> | <span class="hljs-built_in">boolean</span>;
multiType = <span class="hljs-number">42</span>; <span class="hljs-comment">// Valid</span>
multiType = <span class="hljs-string">"TypeScript"</span>; <span class="hljs-comment">// Valid</span>
multiType = <span class="hljs-literal">false</span>; <span class="hljs-comment">// Valid</span>
</code></pre>
<h5 id="heading-when-to-use-union-types">When to use union types:</h5>
<ul>
<li><p><strong>Flexible function parameters</strong>: When a function can accept multiple types of input.</p>
<pre><code class="lang-typescript">  typescriptCopyEditfunction printValue(value: <span class="hljs-built_in">string</span> | <span class="hljs-built_in">number</span>) {
    <span class="hljs-built_in">console</span>.log(value);
  }
</code></pre>
</li>
<li><p><strong>Handling diverse data structures</strong>: When working with APIs or external data sources where fields may vary in type.</p>
</li>
<li><p><strong>Optional or multi-state variables</strong>: For example, a variable that can represent a loading state as a boolean, an error as a string, or valid data as an object:</p>
<pre><code class="lang-typescript">  typescriptCopyEditlet status: <span class="hljs-built_in">boolean</span> | <span class="hljs-built_in">string</span> | { success: <span class="hljs-built_in">boolean</span>; data: <span class="hljs-built_in">any</span> };
</code></pre>
</li>
</ul>
<h2 id="heading-how-to-handle-objects-arrays-and-function-types-in-typescript">How to Handle Objects, Arrays, and Function Types in TypeScript</h2>
<p>To master TypeScript, you must understand the various data types supported in TypeScript and how and when to use them.</p>
<p>The <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#primitive_values">JavaScript primitive types</a> such as <em>strings</em>, <em>numbers</em>, <em>booleans</em>, and more also define the fundamental building blocks of data in TypeScript. But in particular, <code>Objects</code><em>,</em> <code>Arrays</code><em>,</em> and <code>Functions</code> are essential for building robust applications. With objects, arrays, and functions, you can better handle data and use them efficiently in development.</p>
<h3 id="heading-object-types-in-typescript">Object Types in TypeScript</h3>
<p>Object types represent the blueprint for creating objects in TypeScript. You can use objects to define their shape, similar to how <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes">classes</a> are used in <strong>object-oriented programming (OOP)</strong>. But objects lack the behavioral aspects and encapsulation that classes offer.</p>
<p>To define an object type, explicitly define the object's blueprint after the colon(<code>:</code>). For Example:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// Object Type Initialization</span>

<span class="hljs-keyword">let</span> student: {
    name: <span class="hljs-built_in">string</span>;
    age: <span class="hljs-built_in">number</span>;
    matricNumber: <span class="hljs-built_in">string</span> | <span class="hljs-built_in">number</span>;
 };

<span class="hljs-comment">// Assigning the Object with actual data</span>

student = {
    name: <span class="hljs-string">"Akande"</span>
    age: <span class="hljs-number">21</span>,
    matricNumber: <span class="hljs-number">21</span>/<span class="hljs-number">52</span> + <span class="hljs-string">"HP"</span> + <span class="hljs-number">19</span>,
};
</code></pre>
<p>Notice that the properties end with a semi-colon<code>;</code> instead of a comma <code>,</code> which ends them in an actual object.</p>
<p>The above is the primary way to define an object in TypeScript. Another way is to use <code>interfaces</code>, which I’ll cover later in this article.</p>
<h3 id="heading-array-types-in-typescript">Array Types in TypeScript</h3>
<p>Arrays in TypeScript allow you to store multiple values of the same or different data types in a single variable. They enhance the safety and clarity of your code by enforcing type consistency across the array elements.</p>
<p>In TypeScript, array types can be defined in two ways:</p>
<h4 id="heading-1-using-the-array-model"><strong>1. Using the</strong> <code>Array&lt;type&gt;</code> model</h4>
<p>This syntax uses the generic <code>Array</code> type, where <code>type</code> represents the type of elements the array can hold.</p>
<pre><code class="lang-typescript">typescriptCopyEditlet numbers: <span class="hljs-built_in">Array</span>&lt;<span class="hljs-built_in">number</span>&gt; = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-keyword">let</span> mixedArray: <span class="hljs-built_in">Array</span>&lt;<span class="hljs-built_in">number</span> | <span class="hljs-built_in">string</span>&gt; = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-string">"Hello"</span>];
</code></pre>
<ul>
<li><p><code>numbers</code> Example: This array can only contain numbers. Attempting to add a string or other type to this array will result in a type error.</p>
<pre><code class="lang-typescript">  typescriptCopyEditnumbers.push(<span class="hljs-number">6</span>); <span class="hljs-comment">// Valid</span>
  numbers.push(<span class="hljs-string">"Hello"</span>); <span class="hljs-comment">// Error: Type 'string' is not assignable to type 'number'</span>
</code></pre>
</li>
<li><p><code>mixedArray</code> Example: This array uses a union type (<code>number | string</code>), allowing it to store both numbers and strings.</p>
<pre><code class="lang-typescript">  typescriptCopyEditmixedArray.push(<span class="hljs-number">42</span>); <span class="hljs-comment">// Valid</span>
  mixedArray.push(<span class="hljs-string">"TypeScript"</span>); <span class="hljs-comment">// Valid</span>
  mixedArray.push(<span class="hljs-literal">true</span>); <span class="hljs-comment">// Error: Type 'boolean' is not assignable to type 'number | string'</span>
</code></pre>
</li>
</ul>
<h4 id="heading-2-using-the-type-model"><strong>2. Using the</strong> <code>type[]</code> model</h4>
<p>This syntax appends square brackets (<code>[]</code>) to the type of elements the array can hold.</p>
<pre><code class="lang-typescript">typescriptCopyEditconst numbers: <span class="hljs-built_in">number</span>[] = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-keyword">const</span> mixedArray: (<span class="hljs-built_in">string</span> | <span class="hljs-built_in">number</span>)[] = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-string">"Hello"</span>];
</code></pre>
<ul>
<li><p><code>numbers</code> Example: Similar to the <code>Array&lt;number&gt;</code> example, this array can only hold numbers.</p>
<pre><code class="lang-typescript">  typescriptCopyEditnumbers[<span class="hljs-number">0</span>] = <span class="hljs-number">10</span>; <span class="hljs-comment">// Valid</span>
  numbers.push(<span class="hljs-string">"Hi"</span>); <span class="hljs-comment">// Error: Type 'string' is not assignable to type 'number'</span>
</code></pre>
</li>
<li><p><code>mixedArray</code> Example: Like the earlier <code>mixedArray</code>, this array allows both numbers and strings, providing flexibility where the type of data may vary.</p>
<pre><code class="lang-typescript">  typescriptCopyEditmixedArray[<span class="hljs-number">1</span>] = <span class="hljs-string">"World"</span>; <span class="hljs-comment">// Valid</span>
  mixedArray.push(<span class="hljs-literal">true</span>); <span class="hljs-comment">// Error: Type 'boolean' is not assignable to type 'string | number'</span>
</code></pre>
</li>
</ul>
<h3 id="heading-how-to-use-arrays-in-typescript"><strong>How to Use Arrays in TypeScript</strong></h3>
<p>Arrays are versatile and commonly used for storing collections of related data. Here are a few practical scenarios:</p>
<p><strong>Storing Homogeneous Data:</strong><br>When all elements in the array share the same type, such as a list of user IDs or product prices:</p>
<pre><code class="lang-typescript">typescriptCopyEditconst userIds: <span class="hljs-built_in">number</span>[] = [<span class="hljs-number">101</span>, <span class="hljs-number">102</span>, <span class="hljs-number">103</span>];
<span class="hljs-keyword">const</span> productPrices: <span class="hljs-built_in">Array</span>&lt;<span class="hljs-built_in">number</span>&gt; = [<span class="hljs-number">29.99</span>, <span class="hljs-number">49.99</span>, <span class="hljs-number">19.99</span>];
</code></pre>
<p><strong>Storing Heterogeneous Data:</strong><br>When elements can have different types, such as a list of messages containing text and optional metadata:</p>
<pre><code class="lang-typescript">typescriptCopyEditconst messages: (<span class="hljs-built_in">string</span> | <span class="hljs-built_in">object</span>)[] = [
  <span class="hljs-string">"Welcome"</span>,
  { <span class="hljs-keyword">type</span>: <span class="hljs-string">"error"</span>, text: <span class="hljs-string">"Something went wrong"</span> },
];
</code></pre>
<p><strong>Iterating Over Arrays:</strong><br>Arrays in TypeScript can be used in loops with full type safety:</p>
<pre><code class="lang-typescript">typescriptCopyEditconst scores: <span class="hljs-built_in">number</span>[] = [<span class="hljs-number">80</span>, <span class="hljs-number">90</span>, <span class="hljs-number">70</span>];
scores.forEach(<span class="hljs-function">(<span class="hljs-params">score</span>) =&gt;</span> <span class="hljs-built_in">console</span>.log(score + <span class="hljs-number">5</span>)); <span class="hljs-comment">// Adds 5 to each score</span>
</code></pre>
<p><strong>Function Parameters and Return Types:</strong><br>Arrays can also be passed as function parameters or returned by functions with strict typing:</p>
<pre><code class="lang-typescript">typescriptCopyEditfunction getNumbers(): <span class="hljs-built_in">number</span>[] {
  <span class="hljs-keyword">return</span> [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
}
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">printStrings</span>(<span class="hljs-params">strings: <span class="hljs-built_in">string</span>[]</span>): <span class="hljs-title">void</span> </span>{
  strings.forEach(<span class="hljs-function">(<span class="hljs-params">str</span>) =&gt;</span> <span class="hljs-built_in">console</span>.log(str));
}
</code></pre>
<h3 id="heading-function-types-in-typescript">Function Types in TypeScript</h3>
<p>Function types in TypeScript describe the shape of functions, including parameter types and return types. Function types are defined by explicitly specifying the parameter types during declaration. The return type is specified by adding <code>:</code> and the type to return immediately after the brackets. For Example:</p>
<pre><code class="lang-typescript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addition</span> (<span class="hljs-params">a: <span class="hljs-built_in">number</span>, b: <span class="hljs-built_in">number</span></span>): <span class="hljs-title">number</span> </span>{
<span class="hljs-keyword">return</span> a + b;
}
</code></pre>
<p>The above function takes in two numbers, adds them, and returns a number. The function will not work if any of its arguments are not numbers and if it returns anything else except a number. For example:</p>
<ol>
<li>Calling the function with a string as the argument:</li>
</ol>
<pre><code class="lang-typescript"><span class="hljs-comment">// This won't work because it expects numbers, and one of the arguments is a string</span>

addition(<span class="hljs-number">1</span>, <span class="hljs-string">"two"</span>);
</code></pre>
<ol start="2">
<li>Re-writing the function to return a string:</li>
</ol>
<pre><code class="lang-typescript"><span class="hljs-comment">// Function will return an error because it's returning a string</span>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">addition</span> (<span class="hljs-params">a: <span class="hljs-built_in">number</span>, b: <span class="hljs-built_in">number</span></span>): <span class="hljs-title">string</span> </span>{
    <span class="hljs-keyword">let</span> result = a + b;
    <span class="hljs-keyword">let</span> returnStatement = <span class="hljs-string">`Addition of <span class="hljs-subst">${a}</span> and <span class="hljs-subst">${b}</span> is: <span class="hljs-subst">${result}</span>`</span>;
    <span class="hljs-keyword">return</span> returnStatement;
}
</code></pre>
<p>Test the code out for yourself to see how these examples work.</p>
<p>Understanding and effectively handling objects, arrays, and functions in TypeScript empowers you to write type-safe and maintainable code, enhancing the reliability and scalability of your applications.</p>
<h2 id="heading-how-to-create-custom-types-in-typescript">How to Create Custom Types in TypeScript</h2>
<p>Often, your design pattern doesn't follow the built-in data types in TypeScript. For example, you might have patterns that use dynamic programming). And this can cause problems in your codebase. TypeScript offers a solution for creating <strong>custom types</strong> to address this issue.</p>
<p>Custom types allow you to define your data structure and shapes according to your needs. This enhances code readability and maintainability.</p>
<h3 id="heading-the-type-keyword">The Type Keyword</h3>
<p>The <code>type</code> keyword lets you create <strong>type aliases</strong>, providing a way to create custom types. The types you create can be reused throughout your codebase. Type aliases help define union types or combine types into single aliases. The syntax for creating a custom type is as follows:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// Syntax</span>

<span class="hljs-keyword">type</span> TypeAlias = <span class="hljs-keyword">type</span>;
</code></pre>
<p>And here’s an example:</p>
<p><img src="https://i.ibb.co/qBZ3Zcw/Screenshot-2024-02-16-at-4-17-27-PM.png" alt="type Example" width="600" height="400" loading="lazy"></p>
<p>The code above creates a custom-type <code>UserName</code>, a union of numbers and strings. It uses the type created to define two variables relatively to check if the type works.</p>
<p>Note that it’s recommended to start a type alias starts with a capital letter.</p>
<p>The type Keyword is generally used for primitives – but how about creating a custom object type?</p>
<p>This is where <strong>Interfaces</strong> come in.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1737294121435/5be475e2-efae-428e-b9ed-bbcce7ce260d.jpeg" alt="5be475e2-efae-428e-b9ed-bbcce7ce260d" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h3 id="heading-typescript-interfaces">TypeScript Interfaces</h3>
<p>Interfaces in TypeScript are used to define the structure of objects. They serve as blueprints, specifying the properties an object should have and their respective types. This ensures that objects conform to a consistent shape, enabling type safety and clearer code.</p>
<h4 id="heading-defining-an-interface">Defining an interface</h4>
<p>An interface is defined using the <code>interface</code> keyword. The syntax looks like this:</p>
<pre><code class="lang-typescript">typescriptCopyEditinterface InterfaceName {
  property1: Type;
  property2: Type;
}
</code></pre>
<h4 id="heading-example">Example:</h4>
<pre><code class="lang-typescript">typescriptCopyEditinterface User {
  id: <span class="hljs-built_in">number</span>;
  name: <span class="hljs-built_in">string</span>;
  email: <span class="hljs-built_in">string</span>;
}

<span class="hljs-keyword">const</span> user: User = {
  id: <span class="hljs-number">1</span>,
  name: <span class="hljs-string">"Alice"</span>,
  email: <span class="hljs-string">"alice@example.com"</span>,
};
</code></pre>
<p>Here’s what’s going on in this example:</p>
<ol>
<li><p><strong>Interface declaration (</strong><code>interface User</code>):</p>
<ul>
<li><p>Here, we define a blueprint for a <code>User</code> object. It specifies that any object of type <code>User</code> must have the following properties:</p>
<ul>
<li><p><code>id</code> of type <code>number</code></p>
</li>
<li><p><code>name</code> of type <code>string</code></p>
</li>
<li><p><code>email</code> of type <code>string</code></p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>Using the interface (</strong><code>const user: User</code>):</p>
<ul>
<li><p>We declare an object <code>user</code> of type <code>User</code>.</p>
</li>
<li><p>The object is required to have all the properties defined in the <code>User</code> interface, with values of the specified types. If a property is missing or its type doesn't match, TypeScript will throw a compile-time error.</p>
</li>
</ul>
</li>
</ol>
<p>    For example:</p>
<pre><code class="lang-typescript">    typescriptCopyEditconst invalidUser: User = {
      id: <span class="hljs-number">1</span>,
      name: <span class="hljs-string">"Alice"</span>,
      <span class="hljs-comment">// Error: Property 'email' is missing in type</span>
    };
</code></pre>
<p>So you might be wondering – why should you use interfaces?</p>
<ul>
<li><p><strong>Type safety</strong>: Ensures that objects conform to the expected structure, preventing runtime errors.</p>
</li>
<li><p><strong>Reusability</strong>: The same interface can be reused across different parts of the application, reducing duplication.</p>
</li>
<li><p><strong>Code clarity</strong>: Makes the code easier to read and understand by explicitly describing the shape of objects.</p>
</li>
</ul>
<h4 id="heading-advanced-features-of-interfaces">Advanced Features of Interfaces</h4>
<ol>
<li><p><strong>Optional properties</strong>: You can make properties optional by adding a question mark (<code>?</code>).</p>
<pre><code class="lang-typescript"> typescriptCopyEditinterface Product {
   id: <span class="hljs-built_in">number</span>;
   name: <span class="hljs-built_in">string</span>;
   description?: <span class="hljs-built_in">string</span>; <span class="hljs-comment">// Optional property</span>
 }

 <span class="hljs-keyword">const</span> product: Product = {
   id: <span class="hljs-number">101</span>,
   name: <span class="hljs-string">"Laptop"</span>,
 }; <span class="hljs-comment">// Valid, as 'description' is optional</span>
</code></pre>
</li>
<li><p><strong>Readonly properties</strong>: Use <code>readonly</code> to prevent properties from being modified after initialization.</p>
<pre><code class="lang-typescript"> typescriptCopyEditinterface Point {
   <span class="hljs-keyword">readonly</span> x: <span class="hljs-built_in">number</span>;
   <span class="hljs-keyword">readonly</span> y: <span class="hljs-built_in">number</span>;
 }

 <span class="hljs-keyword">const</span> point: Point = { x: <span class="hljs-number">10</span>, y: <span class="hljs-number">20</span> };
 point.x = <span class="hljs-number">15</span>; <span class="hljs-comment">// Error: Cannot assign to 'x' because it is a read-only property</span>
</code></pre>
</li>
<li><p><strong>Extending interfaces</strong>: Interfaces can inherit properties from other interfaces, enabling composition.</p>
<pre><code class="lang-typescript"> typescriptCopyEditinterface Person {
   name: <span class="hljs-built_in">string</span>;
   age: <span class="hljs-built_in">number</span>;
 }

 <span class="hljs-keyword">interface</span> Employee <span class="hljs-keyword">extends</span> Person {
   employeeId: <span class="hljs-built_in">number</span>;
 }

 <span class="hljs-keyword">const</span> employee: Employee = {
   name: <span class="hljs-string">"John"</span>,
   age: <span class="hljs-number">30</span>,
   employeeId: <span class="hljs-number">1234</span>,
 };
</code></pre>
</li>
</ol>
<h3 id="heading-when-to-use-interfaces"><strong>When to Use Interfaces</strong></h3>
<p>There are various scenarios when it’s a good idea to use interfaces. You can use them when you want to define and enforce the structure of objects passed around in your code.</p>
<p>They’re also useful in API responses, as they help you type-check objects received from APIs. This ensures that the data conforms to your expectations.</p>
<p>Interfaces are also handy when working with reusable types. When multiple parts of your application use objects with the same structure, interfaces prevent duplication.</p>
<p>By leveraging interfaces, you can create robust, maintainable, and type-safe applications. They are an essential feature of TypeScript that promotes clean and predictable code.</p>
<h3 id="heading-generics-and-literal-types">Generics and Literal Types</h3>
<p><strong>Generics</strong> in TypeScript allow you to create reusable components that can work with various data types. They let you write functions, classes, and interfaces without specifying the exact type upfront, making your code more flexible and maintainable.</p>
<p>Here's an example of a generic function and a generic interface in TypeScript:</p>
<pre><code class="lang-typescript"><span class="hljs-comment">// Generic interface for a box that can hold any value </span>

<span class="hljs-keyword">interface</span>  Box&lt;T&gt; { 
    value: T; 
}

<span class="hljs-comment">// Usage examples</span>

<span class="hljs-keyword">let</span>  numberBox: Box&lt;<span class="hljs-built_in">number</span>&gt; = { value: <span class="hljs-number">10</span> };
<span class="hljs-keyword">let</span>  stringBox: Box&lt;<span class="hljs-built_in">string</span>&gt; = { value: <span class="hljs-string">"TypeScript"</span> };

<span class="hljs-built_in">console</span>.log(numberBox.value); <span class="hljs-comment">// Output: 10  </span>
<span class="hljs-built_in">console</span>.log(stringBox.value); <span class="hljs-comment">// Output: TypeScript</span>
</code></pre>
<p>You can use generics when you’re unsure of your data type.</p>
<p>In contrast to Generics, <strong>Literal types</strong> allow you to specify exact values a variable can hold. This adds increased specificity and type safety to your code, preventing unintended values from being assigned. Here’s an example:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">type</span> Direction = <span class="hljs-string">'up'</span> | <span class="hljs-string">'down'</span> | <span class="hljs-string">'left'</span> | <span class="hljs-string">'right'</span>;
</code></pre>
<p>A variable created with the above type can only be assigned for the strings up, down, left, and right.</p>
<p>Overall, leveraging custom types in TypeScript empowers you to create expressive, reusable, and type-safe data structures, helping you develop more robust and maintainable applications.</p>
<h2 id="heading-how-to-merge-types-in-typescript">How to Merge Types in TypeScript</h2>
<p>Merging types in TypeScript combines multiple type declarations into a single, unified type. This capability allows developers to build complex types from smaller, reusable pieces, enhancing code clarity, reusability, and maintainability.</p>
<h3 id="heading-1-declaration-merging-in-interfaces"><strong>1. Declaration Merging in Interfaces</strong></h3>
<p>TypeScript supports <strong>declaration merging</strong>, where multiple interface declarations with the same name are automatically combined into a single interface. This lets you augment an existing interface by defining additional properties or methods.</p>
<h5 id="heading-example-1"><strong>Example:</strong></h5>
<pre><code class="lang-typescript">typescriptCopyEditinterface User {
  id: <span class="hljs-built_in">number</span>;
  name: <span class="hljs-built_in">string</span>;
}

<span class="hljs-keyword">interface</span> User {
  email: <span class="hljs-built_in">string</span>;
}

<span class="hljs-keyword">const</span> user: User = {
  id: <span class="hljs-number">1</span>,
  name: <span class="hljs-string">"Alice"</span>,
  email: <span class="hljs-string">"alice@example.com"</span>,
};
</code></pre>
<h5 id="heading-how-it-works"><strong>How it works:</strong></h5>
<ul>
<li><p>The <code>User</code> interface is declared twice, each with different properties.</p>
</li>
<li><p>TypeScript automatically merges these declarations into a single interface:</p>
<pre><code class="lang-typescript">  typescriptCopyEditinterface User {
    id: <span class="hljs-built_in">number</span>;
    name: <span class="hljs-built_in">string</span>;
    email: <span class="hljs-built_in">string</span>;
  }
</code></pre>
</li>
<li><p>When creating the <code>user</code> object, all properties from the merged interface must be present. If any property is missing, TypeScript will raise an error.</p>
</li>
</ul>
<p>Declaration merging is particularly useful when working with third-party libraries. You can extend or add new properties to an existing interface without modifying the library's source code.</p>
<h3 id="heading-2-interface-merging-using-the-extends-keyword"><strong>2. Interface Merging Using the</strong> <code>extends</code> Keyword</h3>
<p>The <code>extends</code> keyword allows one interface to inherit properties and methods from another, creating a new interface that combines the properties of both.</p>
<h5 id="heading-example-2"><strong>Example:</strong></h5>
<pre><code class="lang-typescript">typescriptCopyEditinterface Person {
  name: <span class="hljs-built_in">string</span>;
  age: <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">interface</span> Employee <span class="hljs-keyword">extends</span> Person {
  employeeId: <span class="hljs-built_in">number</span>;
}

<span class="hljs-keyword">const</span> employee: Employee = {
  name: <span class="hljs-string">"John"</span>,
  age: <span class="hljs-number">30</span>,
  employeeId: <span class="hljs-number">101</span>,
};
</code></pre>
<h5 id="heading-how-it-works-1"><strong>How it works:</strong></h5>
<ul>
<li><p>The <code>Person</code> interface defines two properties: <code>name</code> and <code>age</code>.</p>
</li>
<li><p>The <code>Employee</code> interface uses the <code>extends</code> keyword to inherit the properties from <code>Person</code>.</p>
</li>
<li><p>The <code>Employee</code> interface also adds a new property, <code>employeeId</code>.</p>
</li>
<li><p>The <code>employee</code> object must include all properties from both <code>Person</code> and <code>Employee</code>.</p>
</li>
</ul>
<h5 id="heading-this-approach-is-ideal-for-hierarchical-relationships-for-instance-you-can-define-a-base-interface-for-shared-properties-and-extend-it-for-specialized-types">This approach is ideal for hierarchical relationships. For instance, you can define a base interface for shared properties and extend it for specialized types.</h5>
<h3 id="heading-3-type-merging-using-the-amp-operator"><strong>3. Type Merging Using the</strong> <code>&amp;</code> Operator</h3>
<p>The <code>&amp;</code> operator, known as the intersection type, allows you to combine multiple types into a single type. The resulting type includes all properties and methods from each type.</p>
<h5 id="heading-example-3"><strong>Example:</strong></h5>
<pre><code class="lang-typescript">typescriptCopyEdittype Address = {
  city: <span class="hljs-built_in">string</span>;
  country: <span class="hljs-built_in">string</span>;
};

<span class="hljs-keyword">type</span> ContactInfo = {
  email: <span class="hljs-built_in">string</span>;
  phone: <span class="hljs-built_in">string</span>;
};

<span class="hljs-keyword">type</span> EmployeeDetails = Address &amp; ContactInfo;

<span class="hljs-keyword">const</span> employee: EmployeeDetails = {
  city: <span class="hljs-string">"New York"</span>,
  country: <span class="hljs-string">"USA"</span>,
  email: <span class="hljs-string">"john.doe@example.com"</span>,
  phone: <span class="hljs-string">"123-456-7890"</span>,
};
</code></pre>
<h5 id="heading-how-it-works-2"><strong>How it works:</strong></h5>
<ul>
<li><p><code>Address</code> and <code>ContactInfo</code> are two separate types.</p>
</li>
<li><p><code>EmployeeDetails</code> is an intersection type created using <code>Address &amp; ContactInfo</code>.</p>
</li>
<li><p>The <code>employee</code> object must include all properties from both <code>Address</code> and <code>ContactInfo</code>. Missing or incorrectly typed properties will result in a TypeScript error.</p>
</li>
</ul>
<h5 id="heading-intersection-types-are-helpful-when-you-need-to-combine-unrelated-types-or-create-composite-types-for-specific-use-cases-like-api-responses-that-merge-different-data-structures">Intersection types are helpful when you need to combine unrelated types or create composite types for specific use cases, like API responses that merge different data structures.</h5>
<h3 id="heading-when-to-use-each-of-these-approaches"><strong>When to Use Each of These Approaches</strong></h3>
<ol>
<li><p><strong>Declaration merging:</strong> Use when you want to extend or augment an existing interface, particularly in third-party libraries or shared codebases.</p>
</li>
<li><p><code>extends</code> <strong>keyword</strong>: Use for hierarchical relationships where a base interface can be specialized into more specific types.</p>
</li>
<li><p><strong>Intersection types (</strong><code>&amp;</code>): Use when you need to combine multiple unrelated types into a single type for specific use cases.</p>
</li>
</ol>
<p>By understanding these merging techniques and their implications, you can structure your TypeScript code effectively, improving reusability and maintainability while maintaining type safety.</p>
<h2 id="heading-bundling-and-transformations-in-typescript">Bundling and Transformations in TypeScript</h2>
<p>Not every browser supports the latest JavaScript used by TypeScript. So you can use the <strong>TypeScript compiler</strong>, or <code>tsc</code>, to convert TypeScript code (.ts files) into conventional JavaScript (.js files) that’s universally compatible with all browsers. <code>tsc</code> translates TypeScript-specific elements like types and classes into JavaScript code that browsers can interpret.</p>
<p>To execute TypeScript files, <code>tsc</code> is your go-to. You can install <code>tsc</code> using npm and then transform your .ts files into .js files. To use <code>tsc</code>, just specify the name of the TypeScript file before the <code>tsc</code> command. For instance, if you have a file named <code>app.ts</code>, you can run it by typing:</p>
<pre><code class="lang-bash">tsc app.ts
</code></pre>
<p>Webpack or Parcel are frequently employed to deploy TypeScript code on browsers. These tools bundle all JavaScript files, including those from TypeScript, for improved performance and easier website implementation. They also optimize code loading by reducing its size and enhancing browser speed.</p>
<h2 id="heading-building-better-code-with-typescript">Building Better Code with TypeScript</h2>
<p>Embracing TypeScript as a JavaScript developer opens up possibilities for writing more robust and maintainable code. By understanding the basics and core concepts outlined in this guide, you can leverage TypeScript's static typing system to catch errors early in development, leading to fewer bugs and smoother code maintenance.</p>
<p>By using TypeScript, JavaScript devs can enhance their code quality and productivity. As you continue to explore and practice with TypeScript, you will discover even more powerful features and functionalities.</p>
<p>Keep pushing your boundaries and dive deeper into the world of TypeScript. 😉</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Essential JavaScript Concepts to Know Before Learning React – With Code Examples ]]>
                </title>
                <description>
                    <![CDATA[ You may have seen the shiny technologies like React, Vue, and Angular that promise to revolutionize your front-end development. It's tempting to dive headfirst into these frameworks, eager to build stunning user interfaces. But hold on! Before you em... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/essential-javascript-concepts-before-react/</link>
                <guid isPermaLink="false">66dfae7a77d188f61ea4b29e</guid>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Front-end Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Akande Olalekan Toheeb ]]>
                </dc:creator>
                <pubDate>Tue, 10 Sep 2024 02:27:06 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1723690396380/c9b8a333-4cbe-42c4-bfab-da39f34d3fd4.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>You may have seen the shiny technologies like React, Vue, and Angular that promise to revolutionize your front-end development. It's tempting to dive headfirst into these frameworks, eager to build stunning user interfaces. But hold on! Before you embark on this exciting journey, consider this:</p>
<p>A strong foundation in JavaScript is the cornerstone of any successful front-end project.</p>
<p>In this article, I aim to provide you with the fundamental JavaScript knowledge required to succeed in React and other front-end frameworks. By the end of this piece, you will better understand key JavaScript concepts—such as destructuring, short-circuiting, and fetching data, among others—and how to use them effectively.</p>
<p>Are you ready to improve your JavaScript skills? Let's dive right in 😉</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-how-to-use-template-literals">How to Use Template Literals</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-destructure-objects-and-arrays">How to Destructure Objects and Arrays</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-ternaries-instead-of-ifelse-statements">Ternaries Instead of if/else Statements</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-use-arrow-functions">How to Use Arrow Functions</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-short-circuiting-with-and-or-nullish">Short-Circuiting with &amp;&amp; , ||, and ??</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-use-array-methods">How to Use Array Methods</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-fetch-data">How to Fetch Data</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-you-can-start-react-now">You Can Start React Now</a></p>
</li>
</ul>
<h2 id="heading-how-to-use-template-literals">How to Use Template Literals</h2>
<p>Ever felt like string construction in JavaScript was a bit of a chore? Imagine putting together a birthday message and constantly adding quotes and plus(+) signs to include the name.</p>
<p>Before ES6, that was the reality with string concatenation. Let's say you wanted to greet a user:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> name = prompt(<span class="hljs-string">"What is your name?"</span>);
<span class="hljs-keyword">let</span> greeting = alert(<span class="hljs-string">"Hello, "</span> + name + “!<span class="hljs-string">");</span>
</code></pre>
<p>This code works, but it can get messy when dealing with multiple variables or dynamic content.</p>
<p>Then came template literals! Introduced in ES6, they offer a more elegant way to create strings using backticks (``) instead of quotes. Here's how to rewrite the greeting with template literals:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> name = prompt(<span class="hljs-string">"What is your name?"</span>);
<span class="hljs-keyword">let</span> greetings = alert(<span class="hljs-string">`Hello <span class="hljs-subst">${name}</span>`</span>);
</code></pre>
<p>See the difference? The <code>${name}</code> part tells JavaScript to insert the value of the <code>name</code> variable directly into the string.</p>
<p>Template literals give you the power to perform string interpolation easily in the JavaScript ecosystem, no more clunky concatenation 😉!</p>
<p><strong>The Benefits of Template Literals include:</strong></p>
<ul>
<li><p><strong>Readability:</strong> Your code becomes clearer and easier to understand.</p>
</li>
<li><p><strong>Maintainability:</strong> Updates are simpler since changes are localized within the template literal.</p>
</li>
<li><p><strong>Expressiveness:</strong> You can create multi-line strings and even use functions within them!</p>
</li>
</ul>
<p>Not only do template literals make your life easier, but they're also instrumental in building dynamic components with React. You can, for instance, create dynamic list items, conditionally render components, or format output based on data.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> name = <span class="hljs-string">'Alice'</span>;
<span class="hljs-keyword">const</span> greeting = <span class="hljs-string">`Hello, <span class="hljs-subst">${name}</span>! How are you today?`</span>;
<span class="hljs-built_in">console</span>.log(greeting); <span class="hljs-comment">// Output: Hello, Alice! How are you today?</span>

<span class="hljs-keyword">const</span> items = [<span class="hljs-string">'apple'</span>, <span class="hljs-string">'banana'</span>, <span class="hljs-string">'orange'</span>];
<span class="hljs-keyword">const</span> listItems = items.map(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> <span class="hljs-string">`&lt;li&gt;<span class="hljs-subst">${item}</span>&lt;/li&gt;`</span>).join(<span class="hljs-string">''</span>);
<span class="hljs-keyword">const</span> list = <span class="hljs-string">`&lt;ul&gt;<span class="hljs-subst">${listItems}</span>&lt;/ul&gt;`</span>;
</code></pre>
<p>As you can see, template literals make building dynamic and readable string-based components in React easier.</p>
<h2 id="heading-how-to-destructure-objects-and-arrays">How to Destructure Objects and Arrays</h2>
<p>Destructuring in JavaScript allows you to extract values from arrays or properties from objects into separate variables, providing a concise and efficient way to handle data structures.</p>
<h3 id="heading-how-to-destructure-objects-in-javascript">How to Destructure Objects in JavaScript</h3>
<p>To destructure an object, use curly braces <code>{ }</code> and specify the property names you want to extract. Let's consider an example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> person = {
    <span class="hljs-attr">firstName</span>: <span class="hljs-string">'Olalekan'</span>,
    <span class="hljs-attr">lastName</span>: ‘Akande<span class="hljs-string">',
    middleName: ‘Toheeb’,
    age: 30 
};

const {  lastName , firstName} = person;
console.log(firstName, lastName); // Output: Akande Olalekan</span>
</code></pre>
<p>In this code, we destructured the <code>person</code> object and extracted the <code>firstName</code> and <code>lastName</code> properties into separate variables.</p>
<h4 id="heading-nested-destructuring">Nested Destructuring:</h4>
<p>You can also destructure nested objects:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> address = {
    <span class="hljs-attr">street</span>: <span class="hljs-string">'123 Main St’,
    city: '</span>Ilorin<span class="hljs-string">'
    state: {
        name: '</span>Kwara<span class="hljs-string">',
        abbreviation: '</span>KW<span class="hljs-string">'
    }
};



const { street, city, state: { name } } = address;
console.log(street, city, name); // Output: 123 Main St Ilorin Kwara</span>
</code></pre>
<p><strong>Default Values:</strong></p>
<p>You can provide default values for properties if they are undefined:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> config = {
    <span class="hljs-attr">theme</span>: <span class="hljs-string">'light'</span>
};

<span class="hljs-keyword">const</span> { theme = <span class="hljs-string">'dark'</span> } = config;
<span class="hljs-built_in">console</span>.log(theme); <span class="hljs-comment">// Output: light</span>
</code></pre>
<h4 id="heading-renaming-property">Renaming Property</h4>
<p>Occasionally, you might need to change an existing property name to a different one for better readability or consistency within your project. Destructuring offers a convenient way to achieve this.</p>
<p>Using a different property name within the destructuring assignment can effectively rename the property as you extract it.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> person = {
    <span class="hljs-attr">firstName</span>: <span class="hljs-string">'Olalekan'</span>,
    <span class="hljs-attr">lastName</span>: ‘Akande<span class="hljs-string">',
    middleName: ‘Toheeb’,
    age: 30 
};

const { firstName: givenName, lastName: familyName } = person;
console.log(familyName, givenName); // Output: Akande Olalekan</span>
</code></pre>
<p>In this example, <code>firstName</code> is renamed to <code>givenName</code>, and <code>lastName</code> is renamed <code>familyName</code> during the destructuring process.</p>
<p>This renaming technique can improve code clarity and maintainability, especially when dealing with complex objects.</p>
<h3 id="heading-destructuring-arrays">Destructuring Arrays</h3>
<p>To destructure an array, you use square brackets <code>[]</code> and specify the indices of the elements you want to extract:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-keyword">const</span> [first, second] = numbers;
<span class="hljs-built_in">console</span>.log(first, second, rest); <span class="hljs-comment">// Output: 1 2</span>
</code></pre>
<h3 id="heading-destructuring-in-react">Destructuring in React</h3>
<p>Destructuring is widely used in React components to extract props, state, and context values. It simplifies code and improves readability:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

<span class="hljs-keyword">const</span> MyComponent = <span class="hljs-function">(<span class="hljs-params">{ name, age }</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Hello, {name}!<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>You are {age} years old.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1723980495782/290be34c-171f-4010-b42f-224af48a6cd2.png" alt="destructuring in objects, arrays, rest and spread operators" class="image--center mx-auto" width="600" height="400" loading="lazy"></p>
<h3 id="heading-rest-and-spread-operator">Rest and Spread Operator</h3>
<p>The rest and spread operators are closely related to destructuring.</p>
<h4 id="heading-rest-operator">Rest Operator</h4>
<p>The rest operator (<code>...</code>) collects the remaining elements of an array or object into a new array or object:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-keyword">const</span> [first, ...rest] = numbers;
<span class="hljs-built_in">console</span>.log(rest); <span class="hljs-comment">// Output: [2, 3, 4, 5]</span>
</code></pre>
<h4 id="heading-spread-operator">Spread Operator</h4>
<p>The spread operator also uses <code>...</code> but is used to expand an iterable into individual elements:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">const</span> newArray = [...numbers, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-built_in">console</span>.log(newArray); <span class="hljs-comment">// Output: [1, 2, 3, 4, 5]</span>
</code></pre>
<p>In React, the spread operator is often used to clone arrays or objects, or to pass props to components:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> person = { <span class="hljs-attr">name</span>: <span class="hljs-string">'John'</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">30</span> };
<span class="hljs-keyword">const</span> newPerson = { ...person, <span class="hljs-attr">city</span>: <span class="hljs-string">'New York'</span> };
<span class="hljs-built_in">console</span>.log(newPerson); <span class="hljs-comment">// Output: { name: 'John', age: 30, city: 'New York' }</span>
</code></pre>
<p>Understanding destructuring and the rest/spread operators can help you write more concise and expressive JavaScript code, especially when working with React.</p>
<h2 id="heading-ternaries-instead-of-ifelse-statements">Ternaries Instead of if/else Statements</h2>
<p>Ternary operators offer a concise and fine alternative to traditional <code>if/else</code> statements in JavaScript. They are particularly useful for conditional expressions that return a value based on a condition.</p>
<p><strong>Why Ternaries Over</strong> <strong>if/else</strong>?</p>
<p>While <code>if/else</code> statements are versatile, they can sometimes lead to verbose code, especially when dealing with simple conditional logic. Ternary operators provide a more compact and readable syntax, making your code easier to understand and maintain.</p>
<p><strong>Syntax and Usage</strong></p>
<p>The syntax for a ternary operator is as follows:</p>
<pre><code class="lang-javascript">condition ? expression1 : expression2
</code></pre>
<p>If the <code>condition</code> is true, <code>expression1</code> is evaluated and returned. Otherwise, <code>expression2</code> is evaluated and returned.</p>
<p><strong>Pure Example:</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> age = <span class="hljs-number">19</span>;

<span class="hljs-keyword">const</span> isAdult = age &gt;= <span class="hljs-number">18</span>;
<span class="hljs-keyword">const</span> message = isAdult ? <span class="hljs-string">'You are an adult.'</span> : <span class="hljs-string">'You are a minor.'</span>;
<span class="hljs-built_in">console</span>.log(message);
</code></pre>
<p>The above example will return a message based on the value of the <code>age</code> variable. Can you predict what will be displayed in the console?</p>
<p><strong>Example in React:</strong></p>
<pre><code class="lang-javascript">
<span class="hljs-keyword">const</span> MyComponent = <span class="hljs-function">(<span class="hljs-params">{ isLoggedIn }</span>) =&gt;</span> {
    <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
        {isLoggedIn ? (
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Welcome, user!<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
        ) : (
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Please log in.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
        )}
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
    );
};
</code></pre>
<p>In this React component, the ternary operator renders different content based on the <code>isLoggedIn</code> prop conditionally.</p>
<p><strong>Benefits of Ternary Operators:</strong></p>
<ul>
<li><p><strong>Concise syntax:</strong> Ternary operators provide a more compact way to express conditional logic.</p>
</li>
<li><p><strong>Readability:</strong> They can improve code readability by making conditional expressions more concise and easier to understand.</p>
</li>
<li><p><strong>Efficiency:</strong> Sometimes, ternary operators are more efficient than <code>if/else</code> statements.</p>
</li>
</ul>
<p>By incorporating ternary operators into your JavaScript code, you can write more elegant and efficient programs.</p>
<h2 id="heading-how-to-use-arrow-functions">How to Use Arrow Functions</h2>
<p>Arrow functions, introduced in ES6, provide a concise syntax for defining functions. They are particularly useful in functional programming paradigms and can significantly improve code readability and maintainability.</p>
<p><strong>What are Arrow Functions?</strong></p>
<p>Arrow functions are a shorthand syntax for declaring functions. They have a simpler structure compared to traditional function declarations or expressions. They are often used for short, inline functions.</p>
<p><strong>Syntax:</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> myFunction = <span class="hljs-function">(<span class="hljs-params">arg1, arg2</span>) =&gt;</span> {
    <span class="hljs-comment">// Function body</span>
};
</code></pre>
<p><strong>Key Features:</strong></p>
<ul>
<li><p><strong>Implicit</strong> <strong>this</strong> <strong>binding:</strong> <a target="_blank" href="https://www.freecodecamp.org/news/javascript-arrow-functions-in-depth/#heading-arrow-functions-dont-have-this-binding">Arrow functions do not create their own <code>this</code> context</a>. Instead, they inherit the <code>this</code> value from the enclosing scope, which can be helpful in callback functions and event handlers.</p>
</li>
<li><p><strong>Concise syntax:</strong> The arrow function syntax is often shorter and more readable than traditional declarations.</p>
</li>
<li><p><strong>Implicit return:</strong> For single-line arrow functions with a <code>return</code> statement, the <code>return</code> keyword can be omitted.</p>
</li>
</ul>
<p><strong>Example:</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> greet = <span class="hljs-function"><span class="hljs-params">name</span> =&gt;</span> <span class="hljs-string">`Hello, <span class="hljs-subst">${name}</span>!`</span>;
<span class="hljs-built_in">console</span>.log(greet(<span class="hljs-string">'Akande'</span>)); <span class="hljs-comment">// Output: Hello, Akande!</span>
</code></pre>
<h3 id="heading-using-arrow-functions-in-react">Using Arrow Functions in React</h3>
<p>Arrow functions are commonly used in React components for various purposes, including:</p>
<ul>
<li><strong>Event handlers:</strong></li>
</ul>
<pre><code class="lang-javascript">&lt;button onClick={<span class="hljs-function">() =&gt;</span> <span class="hljs-built_in">this</span>.handleClick()}&gt;Click me&lt;/button&gt;
</code></pre>
<p><strong>Explanation:</strong> Here, the arrow function is used as the event handler for the <code>onClick</code> event. This ensures that the <code>this</code> context within the handler refers to the component instance, allowing you to access the component's state and methods.</p>
<ul>
<li><strong>Map, filter, and reduce:</strong></li>
</ul>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-keyword">const</span> doubledNumbers = numbers.map(<span class="hljs-function"><span class="hljs-params">number</span> =&gt;</span> number * <span class="hljs-number">2</span>);
</code></pre>
<p><strong>Explanation:</strong> Arrow functions are often used with array methods like map, filter, and reduce to perform transformations on data. In this example, the map method creates a new array where each element is doubled, using an arrow function for the callback.</p>
<p><strong>Props</strong>:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> MyComponent = <span class="hljs-function">(<span class="hljs-params">{ name, onButtonClick }</span>) =&gt;</span> {
    <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{onButtonClick}</span>&gt;</span>Click me<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
    );
};
</code></pre>
<p><strong>Explanation:</strong> Arrow functions can be used to define props that are functions. In this example, the <code>onButtonClick</code> prop is a function that can be passed to the component. When the button is clicked, the <code>onButtonClick</code> function will be called.</p>
<p>By using arrow functions effectively, you can write more concise, readable, and maintainable React code.</p>
<h2 id="heading-short-circuiting-with-ampamp-and">Short-Circuiting with <code>&amp;&amp;</code> , <code>||</code>, and <code>??</code></h2>
<p>Short-circuiting is a JavaScript evaluation technique that can optimize conditional expressions. It involves stopping the evaluation of a logical expression as soon as the final result is determined.</p>
<p>Short-circuiting in logical operators means that, in certain conditions, the operator will immediately return the first value and not even look at the second value.</p>
<p>We can say that short-circuiting depends on the truthy and falsy values</p>
<p>Falsy values include: 0, empty string (‘’), <code>null</code>, <code>undefinded</code>.</p>
<p>Truty values are basically anything that is not fasly value.</p>
<h3 id="heading-when-do-logical-operators-short-circuit">When do logical operators short-circuit?</h3>
<h4 id="heading-logical-and-ampamp">Logical AND (&amp;&amp;)</h4>
<p>The <code>&amp;&amp;</code> operator short circuit when the left-hand side of the operator (first operand) is false (that is, it immediately returns the first value when it’s any of the falsy values). There is no short-circuit if the first operand is truthy, it will return the right-hand side of the operator(second operand).</p>
<p>This is known as short-circuiting to the left.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> isLoggedIn = <span class="hljs-literal">true</span>;
<span class="hljs-keyword">const</span> greeting = isLoggedIn &amp;&amp; <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Welcome, user!<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span></span>;
</code></pre>
<p>In this example, the greeting variable will only be assigned the JSX element if <code>isLoggedIn</code> is true. If <code>isLoggedIn</code> is false, the <code>&amp;&amp;</code> operator will short-circuit, and the JSX element will not be rendered.</p>
<h4 id="heading-logical-or">Logical OR (||)</h4>
<p>The <code>||</code> operator works in the opposite direction as the <code>&amp;&amp;</code> operator. The <code>||</code> operator short circuits when the first operand is true. That is, If the left-hand side of the <code>||</code> operator is true, it immediately returns the second value.</p>
<p>This is known as short-circuiting to the right.</p>
<p><strong>Example:</strong></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> username = <span class="hljs-string">'Akande'</span>;
<span class="hljs-keyword">const</span> greeting = username || ‘Guest<span class="hljs-string">';</span>
</code></pre>
<p>This code will assign <code>greeting</code> the value of <code>username</code> if it's not any of the falsy values. Otherwise, it will assign the default value of <code>Guest</code>.</p>
<p><strong>Note</strong>: You have to be very careful when using the <code>||</code> operator in cases where you might actually wish to return the 0. .</p>
<p>For example</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> numberOfBooksRead = <span class="hljs-number">0</span>;
<span class="hljs-keyword">const</span> hasRead = numberOfBooksRead || ‘No data’;

<span class="hljs-comment">// hasRead = ‘’No data’</span>
</code></pre>
<p>The above will return <code>No data</code> because the first operand—<code>numberOfBooksRead</code> —is a falsy value. In this kind of situation, it’s better to use the nullish coalescing operator (<code>??</code>)</p>
<h4 id="heading-nullish-coalescing-operator">Nullish Coalescing Operator (??)</h4>
<p>Nullish coalescing operator (??) returns the left-hand side operand if it is not <code>null</code> or <code>undefined</code>. Otherwise, it returns the right-hand side operand.</p>
<p>The above example can now be written as</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> numberOfBooksRead = <span class="hljs-number">0</span>;
<span class="hljs-keyword">const</span> hasRead = numberOfBooksRead ?? ‘No data’;  

<span class="hljs-comment">// hasRead = 0;</span>
</code></pre>
<h3 id="heading-optional-chaining">Optional Chaining (?.)</h3>
<p>The optional chaining operator (<code>?.</code>) provides a safer way—in React—to access nested properties without throwing an error if a property is <code>undefined</code> or <code>null</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> user = { <span class="hljs-attr">address</span>: { <span class="hljs-attr">street</span>: <span class="hljs-string">'123 Main St'</span> } };
<span class="hljs-keyword">const</span> street = user?.address?.street;
</code></pre>
<p>In this example, <code>street</code> will be assigned the value of <code>123 Main St</code> if both <code>user</code> and <code>user.address</code> exist. If either is <code>null</code> or <code>undefined</code>, <code>street</code> will be <code>undefined</code> without throwing an error.</p>
<p>Effective usage of <a target="_blank" href="https://www.freecodecamp.org/news/short-circuiting-in-javascript/">short-circuiting</a> and <a target="_blank" href="https://www.freecodecamp.org/news/optional-chaining-javascript/">optional chaining</a> makes you write more concise and robust React components.</p>
<h2 id="heading-how-to-use-array-methods">How to Use Array Methods</h2>
<p>Arrays are fundamental data structures in JavaScript that store collections of elements. They are ordered and can contain elements of different data types.</p>
<h3 id="heading-essential-array-methods">Essential Array Methods</h3>
<ul>
<li><p><strong>map():</strong> Creates a new array by applying a function to each original array element. Use <code>map()</code> to update existing elements.</p>
</li>
<li><p><strong>filter():</strong> Creates a new array containing only elements that pass a test implemented by a provided function. Use <code>filter()</code> to delete elements.</p>
</li>
<li><p><strong>reduce():</strong> Applies a function to an accumulator and each array element to reduce it to a single value.</p>
</li>
<li><p><strong>sort():</strong> Sorts the elements of an array in place.</p>
</li>
</ul>
<h3 id="heading-advanced-array-methods">Advanced Array Methods</h3>
<ul>
<li><p><strong>flatMap():</strong> Flattens an array and applies a mapping function to each element.</p>
</li>
<li><p><strong>reduceRight():</strong> Similar to <code>reduce()</code>, but starts from the end of the array.</p>
</li>
<li><p><strong>find():</strong> Returns the first element in an array that satisfies a test implemented by a provided function.</p>
</li>
</ul>
<h3 id="heading-relating-array-methods-to-react">Relating Array Methods to React</h3>
<p>Array methods are indispensable for working with data in React components. They can transform, filter, and aggregate data to render dynamic UI elements.</p>
<p>Example using <code>map()</code> to update elements:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> items = [<span class="hljs-string">'apple'</span>, <span class="hljs-string">'banana'</span>, <span class="hljs-string">'orange'</span>];
<span class="hljs-keyword">const</span> updatedItems = items.map(<span class="hljs-function"><span class="hljs-params">item</span> =&gt;</span> item === <span class="hljs-string">'apple'</span> ? <span class="hljs-string">'grapefruit'</span> : item);
</code></pre>
<p>In this example, the <code>map()</code> method creates a new array where the element <code>'apple'</code> is replaced with <code>'grapefruit'</code>.</p>
<p>Example using <code>filter()</code> to delete elements:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-keyword">const</span> evenNumbers = numbers.filter(<span class="hljs-function"><span class="hljs-params">number</span> =&gt;</span> number % <span class="hljs-number">2</span> === <span class="hljs-number">0</span>);
</code></pre>
<p>In this example, the <code>filter()</code> method creates a new array containing only the even numbers from the original array.</p>
<p>Example using <code>reduce()</code> to aggregate data:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-keyword">const</span> sum = numbers.reduce(<span class="hljs-function">(<span class="hljs-params">acc, curr</span>) =&gt;</span> acc + curr, <span class="hljs-number">0</span>);
</code></pre>
<p>In this example, the <code>reduce()</code> method calculates the sum of all elements in the numbers array.</p>
<p>Example using <code>flatMap()</code> to flatten an array:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> nestedArrays = [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>], [<span class="hljs-number">3</span>, <span class="hljs-number">4</span>]];
<span class="hljs-keyword">const</span> flattenedArray = nestedArrays.flatMap(<span class="hljs-function"><span class="hljs-params">array</span> =&gt;</span> array);
</code></pre>
<p>In this example, the <code>flatMap()</code> method flattens the nested arrays into a single array.</p>
<h3 id="heading-chaining-array-methods">Chaining Array Methods</h3>
<p>You can chain multiple array methods together to perform complex transformations on data concisely and efficiently.</p>
<p>Example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> users = [
    { <span class="hljs-attr">name</span>: <span class="hljs-string">'Akande'</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">30</span> },
    { <span class="hljs-attr">name</span>: <span class="hljs-string">'Toheeb'</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">25</span> },
    { <span class="hljs-attr">name</span>: <span class="hljs-string">'Olalekan'</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">35</span> }
];

<span class="hljs-keyword">const</span> adultUsers = users
.filter(<span class="hljs-function"><span class="hljs-params">user</span> =&gt;</span> user.age &gt;= <span class="hljs-number">18</span>)
.map(<span class="hljs-function"><span class="hljs-params">user</span> =&gt;</span> ({ <span class="hljs-attr">name</span>: user.name, <span class="hljs-attr">age</span>: user.age }));
</code></pre>
<p>In this example, we first filtered the users based on their age and then mapped over the filtered array to create a new array with only the name and age properties.</p>
<p>By mastering <a target="_blank" href="https://www.freecodecamp.org/news/the-javascript-array-handbook/">array methods</a>, you can write more efficient and expressive React components that effectively handle and manipulate data.</p>
<h2 id="heading-how-to-fetch-data">How to Fetch Data</h2>
<p>Data is the lifeblood of web applications, and React is no exception. Fetching data from external sources, such as APIs, is a fundamental task in React development. This data is used to populate components, update the UI, and provide a dynamic user experience.</p>
<h3 id="heading-promises-and-fetch">Promises and Fetch</h3>
<p>Promises represent the eventual completion (or failure) of an asynchronous operation. The <code>fetch()</code> API is a built-in JavaScript function that returns a Promise representing the fetching of a resource.</p>
<p><strong>Example using</strong> <code>fetch()</code>:</p>
<pre><code class="lang-javascript">fetch(<span class="hljs-string">'https://api.example.com/data'</span>)
    .then(<span class="hljs-function"><span class="hljs-params">response</span> =&gt;</span> response.json())
    .then(<span class="hljs-function"><span class="hljs-params">data</span> =&gt;</span> {
    <span class="hljs-comment">// Handle the data here</span>
    <span class="hljs-built_in">console</span>.log(data);
    })
    .catch(<span class="hljs-function"><span class="hljs-params">error</span> =&gt;</span> {
    <span class="hljs-comment">// Handle errors here</span>
    <span class="hljs-built_in">console</span>.error(error);
    };
</code></pre>
<h3 id="heading-asyncawait">Async/Await</h3>
<p>The <code>async/await</code> syntax provides a cleaner way to work with Promises. It allows you to write asynchronous code in a more synchronous-looking style.</p>
<p>Example using <code>async/await</code>:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fetchData</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">try</span> {
        <span class="hljs-keyword">const</span> response = <span class="hljs-keyword">await</span> fetch(<span class="hljs-string">'https://api.example.com/data'</span>);
        <span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> response.json();
        <span class="hljs-built_in">console</span>.log(data);
    } <span class="hljs-keyword">catch</span> (error) {
    <span class="hljs-built_in">console</span>.error(error);
    }
}

fetchData();
</code></pre>
<h3 id="heading-fetching-data-in-react-components">Fetching Data in React Components</h3>
<p>In React components, you typically fetch data within lifecycle methods like <code>componentDidMount</code> or <code>useEffect</code>. This ensures that data is fetched after the component is mounted and any initial state is set.</p>
<p>Example:</p>
<pre><code class="lang-javascript">
<span class="hljs-keyword">import</span> React, { useEffect, useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyComponent</span>(<span class="hljs-params"></span>) </span>{
<span class="hljs-keyword">const</span> [data, setData] = useState(<span class="hljs-literal">null</span>);

useEffect(<span class="hljs-function">() =&gt;</span> {
    <span class="hljs-keyword">const</span> fetchData = <span class="hljs-keyword">async</span> () =&gt; {
        <span class="hljs-keyword">try</span> {
            <span class="hljs-keyword">const</span> response = <span class="hljs-keyword">await</span> fetch(<span class="hljs-string">'https://api.example.com/data'</span>);
            <span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> response.json();
            setData(data);
            } <span class="hljs-keyword">catch</span> (error) {
            <span class="hljs-built_in">console</span>.error(error);
            }
        };

    fetchData();
}, []);

    <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
        {data ? (
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Data: {JSON.stringify(data)}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
        ) : (
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Loading...<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
        )}
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
    );
}
</code></pre>
<p>In this example, the <code>useEffect</code> hook is used to fetch data when the component mounts. The <code>useState</code> hook is used to manage the loading state and display the fetched data.</p>
<h3 id="heading-error-handling">Error Handling</h3>
<p>It's essential to handle errors that may occur during data fetching. You can use <code>try/catch</code> blocks to catch exceptions and provide appropriate feedback to the user.</p>
<p>By understanding <a target="_blank" href="https://www.freecodecamp.org/news/the-javascript-promises-handbook/"><strong>Promises</strong></a>, <a target="_blank" href="https://www.freecodecamp.org/news/javascript-fetch-api-for-beginners/"><strong>Fetch API</strong></a>, <a target="_blank" href="https://www.freecodecamp.org/news/asynchronous-programming-in-javascript-examples/"><strong>async/await</strong></a>, and <a target="_blank" href="https://www.freecodecamp.org/news/try-catch-in-javascript/"><strong>Error handling</strong></a>, you can effectively fetch and manage data in your React applications.</p>
<h2 id="heading-you-can-start-react-now">You Can Start React Now</h2>
<p>This article explores the essential JavaScript concepts that form the foundation for successful React development.</p>
<p>By mastering template literals, destructuring, ternaries, arrow functions, short-circuiting, array methods, fetch API, and asynchronous/await, you'll be well-equipped to tackle the challenges and opportunities that React presents.</p>
<h3 id="heading-further-learning"><strong>Further Learning</strong></h3>
<p>To deepen your understanding of React, consider checking out the following:</p>
<ul>
<li><p><a target="_blank" href="%5Bhttps://legacy.reactjs.org/docs/getting-started.html%5D(https://legacy.reactjs.org/docs/getting-started.html)**"><strong>Official React Documentation</strong></a></p>
</li>
<li><p><a target="_blank" href="https://create-react-app.dev/"><strong>Create React App</strong></a>: A popular tool for setting up React projects quickly</p>
</li>
<li><p><strong>Online Courses</strong>: Platforms like <a target="_blank" href="https://www.freecodecamp.org/"><strong>freeCodeCamp</strong></a>, <strong>Udemy</strong>, and <strong>Coursera</strong> offer comprehensive React courses.</p>
</li>
<li><p><strong>React Community</strong>: Engage with the React community on forums, social media, and meetups to learn from others and stay updated on the latest trends.</p>
</li>
</ul>
<h3 id="heading-call-to-action">Call to Action</h3>
<p>Now that you have a strong JavaScript foundation, it's time to dive into React and build amazing web applications. Don't be afraid to experiment, make mistakes, and learn from your experiences. The React community is welcoming and supportive, so don't hesitate to ask for help when needed.</p>
<p><strong>Remember:</strong> The journey of mastering React is ongoing. Stay curious, keep learning, and enjoy the process of creating innovative web experiences.</p>
<p>Don't forget to share and recommend this article for anyone who might need it.</p>
<p><img src="https://thumbs2.imgbox.com/ef/4c/4hKjdQ6N_t.jpeg" alt="Thank You Memoji" width="600" height="400" loading="lazy"></p>
<p>Thanks for reading. Let's connect on <a target="_blank" href="https://x.com/devtoheeb">X</a> or <a target="_blank" href="https://www.linkedin.com/in/akande-olalekan-toheeb-2a69a0221">LinkedIn</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Start a Career in Cloud Computing ]]>
                </title>
                <description>
                    <![CDATA[ What comes to mind when you hear the term "the Cloud"? Do you envision the vast expanse of the sky, with its billowy clouds and soaring birds? In the realm of technology, the term "Cloud" has no relation to the atmospheric phenomena or avian inhabita... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-start-a-cloud-computing-career/</link>
                <guid isPermaLink="false">66bb5952b6e566d0c2aea5fa</guid>
                
                    <category>
                        <![CDATA[ career advice ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud Computing ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Akande Olalekan Toheeb ]]>
                </dc:creator>
                <pubDate>Mon, 25 Mar 2024 18:03:41 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/03/Freecodecamp.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>What comes to mind when you hear the term "the Cloud"? Do you envision the vast expanse of the sky, with its billowy clouds and soaring birds?</p>
<p>In the realm of technology, the term "Cloud" has no relation to the atmospheric phenomena or avian inhabitants of the world. Instead, it refers to a form of computing known as Cloud Computing.</p>
<p>Cloud computing has become an in-demand career path within the rapidly evolving tech space. With businesses increasingly shifting their operations to the cloud, the demand for proficient cloud professionals is rising.</p>
<p>In this guide, I'll give you the knowledge necessary to embark on a successful journey into the cloud. From understanding the foundational principles of cloud computing to exploring diverse career paths within the field, this guide will equip you with the tools you'll need to thrive in the dynamic realm of cloud technology.</p>
<h2 id="heading-what-is-cloud-computing">What Is Cloud Computing?</h2>
<p>The IT space is broad, with four major areas: computing, database, storage, and network. These areas have resources that all connect to transmit information using various tools.</p>
<p>Typically, these resources are purchased and placed in a data centre, where they connect to accomplish various computing tasks. At its core, the cloud revolutionises how businesses access and manage their computing resources.</p>
<p>But what is cloud computing exactly?</p>
<p><img src="https://i.ibb.co/1sT4NWC/pexels-photo-325185.webp" alt="Image representation of Cloud Computing" width="600" height="400" loading="lazy"></p>
<blockquote>
<p>Cloud Computing is the on-demand delivery of IT resources over the Internet with pay-as-you-go pricing. [ <a target="_blank" href="https://aws.amazon.com/what-is-cloud-computing/">Source: AWS</a> ]</p>
</blockquote>
<p>Let's understand the key concepts in this definition:</p>
<ul>
<li><p>On-demand: You get resources exactly when you need them.</p>
</li>
<li><p>Over the Internet: You don't need to buy resources or have physical data centers. Just make a request online.</p>
</li>
<li><p>Pay-as-you-go: You only pay for what you use.</p>
</li>
</ul>
<p>Cloud computing offers many benefits to organisations and businesses. These include agility, elasticity, cost savings, scalability, and more. With cloud computing, your team has more power over your data security and disaster recovery efforts.</p>
<p>Cloud computing represents a paradigm shift in how technology is consumed and delivered. Its transformative impact extends across industries, driving efficiency, innovation, and agility in the digital era.</p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/what-is-cloud-computing/">Understanding cloud computing</a> is essential for developers seeking to navigate the evolving landscape of technology and stay up to date with the latest trends.</p>
<h3 id="heading-why-is-cloud-computing-a-good-career-option">Why is Cloud Computing a Good Career Option?</h3>
<p>The cloud offers many benefits to businesses worldwide. It offers flexibility, scalability, and reliability, allowing a company to swiftly scale resources on-demand and adapt to dynamic market conditions.</p>
<p>Top companies such as Netflix, Dropbox, and Rackspace have moved into the cloud because of its great benefits, and many others are rapidly following suit. Because of this, the cloud realm is undergoing a profound transformation.</p>
<p>Moreover, the COVID-19 pandemic has accelerated the shift to remote work and digital transformation, making cloud skills indispensable for businesses across industries.</p>
<p>This rapid adoption has created a surge in demand for cloud experts who can efficiently design, implement, and manage cloud-based systems. Companies are actively hiring cloud experts in different domains to meet their needs.</p>
<p>And so, delving into the cloud is not just advantageous – it's a strategic imperative. Starting a career in cloud computing presents immense opportunities for growth, advancement, and job security. With the right skills and knowledge, you can embark on a rewarding journey in a field that continues to shape the global future of technology and business.</p>
<h2 id="heading-careers-in-cloud-computing">Careers in Cloud Computing</h2>
<p><img src="https://i.ibb.co/DDxDyx7/photo-1454165804606-c3d57bc86b40.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you're ready to start a career in the cloud, here are a few options you can explore:</p>
<h3 id="heading-cloud-architect">Cloud Architect</h3>
<p>Cloud architects design and oversee the implementation of cloud-based solutions, ensuring they meet the organisation's requirements.</p>
<ul>
<li><p><strong>Prerequisite Skills</strong>: Strong understanding of cloud platforms (like AWS, Azure, or Google Cloud), architecture design principles, and experience with networking and security.</p>
</li>
<li><p><strong>Average Time to Acquire Skills</strong>: 3-5 years of experience in IT or related fields, along with specialised training or certification.</p>
</li>
<li><p><strong>Average Salary</strong>: $120,000 - $160,000 per year.</p>
</li>
</ul>
<h3 id="heading-cloud-developer">Cloud Developer</h3>
<p>Cloud developers specialise in creating and deploying applications optimised for cloud environments. They leverage cloud services and platforms to build scalable, resilient, cost-effective solutions.</p>
<ul>
<li><p><strong>Prerequisite Skills</strong>: Proficiency in programming languages (like Python, Java, or JavaScript), familiarity with cloud platforms and services, and experience with software development methodologies.</p>
</li>
<li><p><strong>Average Time to Acquire Skills</strong>: 1-3 years of experience in software development, supplemented by training or certification in cloud technologies.</p>
</li>
<li><p><strong>Average Salary</strong>: $100,000 - $140,000 per year.</p>
</li>
</ul>
<h3 id="heading-cloud-security-engineer">Cloud Security Engineer</h3>
<p>Cloud security engineers focus on safeguarding cloud-based infrastructure and applications from cyber threats and vulnerabilities.</p>
<ul>
<li><p><strong>Prerequisite Skills</strong>: Strong knowledge of cybersecurity principles, familiarity with cloud security best practices, and expertise in security tools and technologies.</p>
</li>
<li><p><strong>Average Time to Acquire Skills</strong>: 2-4 years of experience in cybersecurity or related roles, augmented by specialised training or certification in cloud security.</p>
</li>
<li><p><strong>Average Salary</strong>: $110,000 - $150,000 per year.</p>
</li>
</ul>
<h3 id="heading-devops-engineer">DevOps Engineer</h3>
<p>DevOps engineers bridge the gap between development and operations teams. They help streamline the deployment and management of cloud-based applications through automation, collaboration, and continuous integration/continuous deployment (CI/CD) practices.</p>
<ul>
<li><p><strong>Prerequisite Skills</strong>: Proficiency in scripting and automation tools (like PowerShell and Terraform), experience with containerisation and orchestration platforms (like Docker and Kubernetes), and DevOps methodologies.</p>
</li>
<li><p><strong>Average Time to Acquire Skills</strong>: 2-4 years of experience in software development or system administration, complemented by training or certification in DevOps practices and cloud technologies.</p>
</li>
<li><p><strong>Average Salary</strong>: $120,000 - $160,000 per year.</p>
</li>
</ul>
<h3 id="heading-cloud-data-engineer">Cloud Data Engineer</h3>
<p>Cloud data engineers specialise in designing, building, and maintaining data pipelines and analytics solutions in cloud environments. They leverage cloud-based technologies to ingest, process, and analyse large volumes of data.</p>
<ul>
<li><p><strong>Prerequisite Skills</strong>: Proficiency in data modelling and ETL (Extract, Transform, Load) processes, experience with big data technologies (like Hadoop and Spark), and familiarity with cloud data platforms (like AWS Redshift or Google BigQuery).</p>
</li>
<li><p><strong>Average Time to Acquire Skills</strong>: 2-4 years of experience in data engineering or related fields, supplemented by training or certification in cloud data technologies.</p>
</li>
<li><p><strong>Average Salary</strong>: $110,000 - $150,000 per year.</p>
</li>
</ul>
<p>These career paths represent just a few of the many opportunities available in cloud computing. Each role offers unique challenges and rewards, making cloud computing a diverse and promising field for aspiring IT professionals.<br>You can explore the various cloud providers' certification lists to grasp other career paths.</p>
<h2 id="heading-how-to-start-your-career-in-the-cloud">How to Start Your Career in the Cloud</h2>
<p>Starting a career in the cloud may seem a bit daunting at first. But with the right strategies, you can pave a successful path in this thriving industry.</p>
<p>Here are some helpful strategies to get you started:</p>
<h3 id="heading-learn-the-basics">Learn the basics</h3>
<p>The best way to start something new is to really understand the concept. Learning the basics and concepts of cloud computing is the first step to starting a career in the cloud.</p>
<p>You can start by taking a <a target="_blank" href="https://www.youtube.com/watch?v=jWdEM6XLKqI">course that generally explains the concept of cloud computing</a>. To understand the concept more deeply, you can also read the many <a target="_blank" href="https://www.freecodecamp.org/news/tag/cloud-computing/">articles the freeCodeCamp publication has on cloud computing</a>.</p>
<p>And you can check out this <a target="_blank" href="https://www.freecodecamp.org/news/free-107-hour-aws-cloud-project-bootcamp/">free 107-hour cloud bootcamp course</a> on the freeCodeCamp YouTube channel. It was created by Andrew Brown who has passed every cloud computing certification under the sun and <a target="_blank" href="https://www.exampro.co/">helps train other devs how to do the same</a>.</p>
<p>When it comes to learning the basics of cloud computing, I recommend focusing on the following skills and tools:</p>
<ol>
<li><p><strong>Cloud Service Providers (CSPs)</strong>: Familiarize yourself with leading CSPs such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). Each CSP offers a range of services and tools for cloud computing, and understanding their platforms is essential for practical application.</p>
</li>
<li><p><strong>Virtualization Technologies</strong>: Learn about virtual machines (VMs), containers (like Docker), and orchestration tools like Kubernetes. These technologies are fundamental to cloud infrastructure and deployment, enabling efficient resource utilisation and scalability. Here's a free <a target="_blank" href="https://www.freecodecamp.org/news/learn-docker-and-kubernetes-hands-on-course/">course on Docker and Kubernetes</a> to get you started.</p>
</li>
<li><p><strong>Networking Concepts</strong>: Gain knowledge of networking fundamentals such as IP addressing, routing, VPNs, and load balancing. Understanding how networks operate in the cloud environment is crucial for designing secure, high-performance cloud architectures. Here's a <a target="_blank" href="https://www.freecodecamp.org/news/computer-networking-how-applications-talk-over-the-internet/">beginner-friendly networking tutorial</a> for you.</p>
</li>
<li><p><strong>Storage Solutions</strong>: Explore cloud storage options like object storage (for example, AWS S3, Azure Blob Storage), file storage (for example, AWS EFS, Azure Files), and database services (for example, AWS RDS, Azure SQL Database). These services play a vital role in managing data effectively in the cloud. Here's a helpful guide that <a target="_blank" href="https://www.freecodecamp.org/news/cloud-storage-options/">explains the different types of storage options</a>.</p>
</li>
<li><p><strong>Security Practices</strong>: Learn about <a target="_blank" href="https://www.freecodecamp.org/news/how-to-secure-your-workloads-on-aws/">cloud security</a> <a target="_blank" href="https://www.freecodecamp.org/news/terraform-security-best-practices/">best practices</a>, <a target="_blank" href="https://www.freecodecamp.org/news/aws-iam-explained/">identity and access management (IAM)</a>, <a target="_blank" href="https://www.freecodecamp.org/news/encryption-explained-in-plain-english/">encryption techniques</a>, and compliance standards (like GDPR and HIPAA). Security is paramount in the cloud, and knowledge of security measures is essential for protecting cloud environments and data.</p>
</li>
<li><p><strong>Monitoring and Management Tools</strong>: Familiarize yourself with cloud monitoring and management tools such as AWS CloudWatch, Azure Monitor, and GCP Stackdriver. These tools help monitor performance, manage resources, and optimise cloud infrastructure.</p>
</li>
</ol>
<h3 id="heading-choose-a-specialization">Choose a Specialization</h3>
<p>Now that you understand the concept, the next step is to specialise. Identify a niche or specialisation within cloud computing that aligns with your interests and career goals.</p>
<p>Specialising will set you apart from other candidates, whether it's cloud security, DevOps, data analytics, or infrastructure management.</p>
<p>Here are some insights and tips to help you choose a specialisation:</p>
<h4 id="heading-assess-your-interests-and-strengths">Assess Your Interests and Strengths</h4>
<p>Consider your interests, strengths, and previous experience in IT. If you enjoy working with data and analytics, consider specialising in cloud data engineering or data analytics. If you excel in problem-solving and system design, cloud architecture or solutions architecture could be a suitable specialisation.</p>
<h4 id="heading-evaluate-your-skills">Evaluate Your Skills</h4>
<p>Take stock of your technical skills and knowledge. If you have a strong background in programming and development, cloud development or DevOps could be a good fit. If you are proficient in networking and security, consider specialising in cloud security or networking on the cloud.</p>
<h4 id="heading-research-market-demand">Research Market Demand</h4>
<p>Explore job trends and market demand for different cloud specialisations. Identify areas with high demand and growth potential.</p>
<p>For example, cloud security professionals are in high demand due to increasing cybersecurity threats, while cloud architects are sought after for designing scalable and resilient cloud solutions.</p>
<h4 id="heading-seek-guidance-and-mentorship">Seek Guidance and Mentorship</h4>
<p>Reach out to people working in different cloud specialisations for insights and advice. Mentorship programs and networking communities can provide valuable guidance in choosing the right specialisation and advancing your cloud career.</p>
<h3 id="heading-choose-the-proper-certifications">Choose the proper certifications</h3>
<p>Obtain industry-recognized certifications that align with your chosen path. Certifications from cloud providers like the AWS Certified Solutions Architect, Microsoft Certified: AzureAdministrator or Google Cloud Professional Cloud Architect validate your skills and enhance your credibility in the job market.</p>
<p>Again, Andrew Brown has created many courses to help you study for and pass these exams. You can <a target="_blank" href="https://www.freecodecamp.org/news/author/andrew/">find his course articles here</a>.</p>
<h3 id="heading-build-your-portfolio">Build your Portfolio</h3>
<p>Build your portfolio by solving real-life problems with your cloud skills. Your cloud solutions to real-life problems are proof that you are skilled.</p>
<p>Cloud providers usually have hands-on projects to work on as you take their course. These courses are sometimes fun in the form of a game, for example <a target="_blank" href="https://aws.amazon.com/training/digital/aws-cloud-quest/">the AWS Cloud quest</a> and sometimes technical, for example <a target="_blank" href="https://cloud.google.com/learn/training/">Google cloud courses</a>. Taking courses that have hands-on projects helps in building your portfolio.</p>
<p>You can also attend cloud workshops. Workshops help build your portfolio because you can work on projects and get some guidance along the way. <a target="_blank" href="https://microsoftcloudworkshop.com/">Microsoft</a>, <a target="_blank" href="https://cloud.google.com/developers/workshops">Google Cloud</a>, and <a target="_blank" href="https://workshops.aws/">AWS</a> all offer cloud workshops and training.</p>
<h3 id="heading-networking">Networking</h3>
<p>Build a professional network by attending industry events, joining online forums and communities, and connecting with professionals in the field. Networking can lead to valuable mentorships, job opportunities, and insights into the industry.</p>
<h3 id="heading-stay-updated">Stay Updated</h3>
<p>Stay abreast of the latest cloud computing trends, technologies, and developments. Work on upskilling yourself through continuous learning, attending workshops, and pursuing advanced certifications as you progress in your career.</p>
<h3 id="heading-apply-for-jobs">Apply for Jobs</h3>
<p>Now that you have fortified yourself with valuable skills, you can start applying for jobs.</p>
<p>Following the above strategies, you can acquire relevant skills, gain practical experience, and navigate the job market, setting yourself on a path to a rewarding and successful career in cloud computing.</p>
<h2 id="heading-the-time-is-now">The Time Is Now</h2>
<p><img src="https://i.ibb.co/Jxj64Ns/IMG-4902.jpg" alt="Encouragement" width="600" height="400" loading="lazy"></p>
<p>As you reflect on the insights shared in this guide, think about the immense potential and opportunities awaiting in the realm of cloud computing. The demand for skilled cloud professionals continues to surge, making it an opportune moment to embark on this transformative career path.</p>
<p>You can start your journey into the cloud today. By acquiring relevant skills, gaining practical experience, and staying updated with industry trends, you can position yourself for success in this dynamic and rapidly evolving field.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
