<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Anushka</title>
    <description>The latest articles on Forem by Anushka (@anushka200310).</description>
    <link>https://forem.com/anushka200310</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1113067%2F2e48eeb7-9d12-4758-8143-289c823a0d95.jpeg</url>
      <title>Forem: Anushka</title>
      <link>https://forem.com/anushka200310</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/anushka200310"/>
    <language>en</language>
    <item>
      <title>TypeScript Chronicles: Navigating the World of Typed JavaScript🚀</title>
      <dc:creator>Anushka</dc:creator>
      <pubDate>Mon, 22 Apr 2024 08:36:30 +0000</pubDate>
      <link>https://forem.com/anushka200310/typescript-chronicles-navigating-the-world-of-typed-javascript-5122</link>
      <guid>https://forem.com/anushka200310/typescript-chronicles-navigating-the-world-of-typed-javascript-5122</guid>
      <description>&lt;p&gt;In the dynamic landscape of web development, TypeScript is a trusty ally for developers. It adds some helpful features to JavaScript, making coding easier and less error-prone.&lt;/p&gt;

&lt;p&gt;In this post, we'll take a closer look at Typescript and how it can make your coding life better.&lt;/p&gt;

&lt;p&gt;Let's dive in!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting up TypeScript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step 1&lt;/em&gt; - Install TypeScript globally&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g typescript
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Step 2&lt;/em&gt; - Initialize an empty node.js project with tsc&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir ts-app
cd ts-app
npm init -y
npx tsc --init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*All the above commands will initialize package.json and tsconfig.json files in your project&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step 3&lt;/em&gt; - Now create a index.ts file in ts-app directory&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdgru1f3v6z8zlk057fql.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdgru1f3v6z8zlk057fql.png" alt="tsc hello world code" width="507" height="181"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Step 4&lt;/em&gt; - Compile the ts file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tsc -b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;it will generate a new index.js file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpnh1ekfjseffyndiwl1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffpnh1ekfjseffyndiwl1.png" alt="js file" width="432" height="206"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice, this is plain JavaScript code with no types&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TypeScript vs. JavaScript: Bridging the Gap&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TypeScript is a superset of JavaScript. It allows developers to  declare types explicitly making it easy to catch error at compile time &lt;/p&gt;

&lt;p&gt;While JavaScript is a powerful flexible language but loosely typed which can lead to unexpected errors, especially in larger projects.&lt;/p&gt;

&lt;p&gt;let's try assigning x to a number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x: string = "Hello world!";
x = 1
console.log(x);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Try to compile the code again. And it will throw an error&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffmcx156k9xsq2x202pwh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffmcx156k9xsq2x202pwh.png" alt="error" width="752" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the benefit of TypeScript. It adds a layer of safety by allowing you to specify the types of data your code expects. &lt;/p&gt;

&lt;p&gt;To know more about the types you can go through the official docs of TypeScript &lt;a href="https://www.typescriptlang.org/docs/handbook/2/everyday-types.html"&gt;ts docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;tsconfig file&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;tsconfig file has many options available. You can also change those to change the process of compilation&lt;/p&gt;

&lt;p&gt;If you want to learn about the tsconfig file and its usability in compilation process in depth you can go through this article 👉 &lt;a href="https://www.scaler.com/topics/typescript/tsconfig-json/"&gt;tsconfig-indepth&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interfaces&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;you can assign types to objects using interfaces&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcfo47631w8943ge7mm0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcfo47631w8943ge7mm0g.png" alt="interface example" width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;type can be used to combine existing types or create complex types.&lt;br&gt;
with type you can create &lt;em&gt;union&lt;/em&gt; types and &lt;em&gt;intersection&lt;/em&gt; types easily&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1kg6tp8sqtm8qomvlnmk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1kg6tp8sqtm8qomvlnmk.png" alt="example of type" width="542" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Type vs Interface&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to create a new data type that represents complex types or a combination of existing types, 'type' may be more appropriate. If you're defining the structure of an object, interface is likely the better choice.&lt;/p&gt;

&lt;p&gt;Sometimes it may come down to personal preference. Both type and interface are powerful features of TypeScript, so choose the one that best fits your needs and makes your code easier to understand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enums&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;You can define a set of constants using&lt;/em&gt; &lt;strong&gt;Enums&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generics&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generics&lt;/strong&gt; in TypeScript also provides a way to create reusable components that can work with different data types.&lt;/p&gt;

&lt;p&gt;They are very much useful in libraries and frameworks where the input and output data types may vary&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here are some useful resources for learning TypeScript&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.typescriptlang.org/docs/"&gt;ts-docs&lt;/a&gt;&lt;br&gt;
&lt;a href="https://devhints.io/typescript"&gt;ts-cheatsheet&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.w3schools.com/typescript/"&gt;ts-tutorial&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.freecodecamp.org/news/learn-typescript-beginners-guide/"&gt;ts-beginners-guide&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy Coding!⭐&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>softwaredevelopment</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Topics You Must Know Before Learning Nodejs</title>
      <dc:creator>Anushka</dc:creator>
      <pubDate>Sat, 13 Jan 2024 10:13:12 +0000</pubDate>
      <link>https://forem.com/anushka200310/topics-you-must-know-before-learning-nodejs-1kjb</link>
      <guid>https://forem.com/anushka200310/topics-you-must-know-before-learning-nodejs-1kjb</guid>
      <description>&lt;p&gt;Hey👋 Devs, welcome to my first post. Currently, I am into Backend development, so thought of writing about the topics which one must know before diving into node.js. So let's go🚀&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asynchronous JavaScript&lt;/strong&gt; - Asynchronous JavaScript is one of the most important topics if you are going to learn node.js next.&lt;br&gt;
Asynchronous programming gives you the power to run a potentially long task and be responsive to other events without waiting for the task to finish.&lt;/p&gt;

&lt;p&gt;If you are thinking about event handlers then you are right✔️&lt;br&gt;
 Event handlers and callbacks are also asynchronous.&lt;/p&gt;

&lt;p&gt;Here's a simple example of asynchronous JavaScript&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// This function makes a network request and logs the response
async function makeRequest() {
  const response = await fetch('https://example.com');
  console.log(response);
}

// This function calls the makeRequest function and logs the result
async function main() {
  const result = await makeRequest();
  console.log(result);
}

main();

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

&lt;/div&gt;



&lt;p&gt;Key topics of asynchronous programming are&lt;br&gt;
i) &lt;strong&gt;Timers&lt;/strong&gt;&lt;br&gt;
ii) &lt;strong&gt;Promises&lt;/strong&gt;&lt;br&gt;
iii) &lt;strong&gt;Async and Await&lt;/strong&gt; &lt;br&gt;
iv) &lt;strong&gt;Closures&lt;/strong&gt; &lt;br&gt;
v) &lt;strong&gt;Event Loop&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;these are fundamental part of Node.js&lt;/p&gt;

&lt;p&gt;Before diving deep with Node.js you should know about 'this' operator, Arrow function, Lexical Structure, Template Literals and be familiar with ES6 and beyond.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Having a good understanding of the HTTP protocol is a must&lt;/strong&gt; - Most common HTTP methods are GET, POST, PATCH, PUT, DELETE, HEAD&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command lines&lt;/strong&gt; -  I won't say that its necessary to have a knowledge about command lines before learning Node.js but its beneficial to have a basic understanding. &lt;/p&gt;

&lt;p&gt;That's it. If you are familiar with the above topics and have knowledge of these then you are ready to dive into the world of backend development using Node.js and Express.js 🚀&lt;/p&gt;

&lt;p&gt;Happy Coding!⭐&lt;/p&gt;

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