<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vaibhav Sahu on Medium]]></title>
        <description><![CDATA[Stories by Vaibhav Sahu on Medium]]></description>
        <link>https://medium.com/@vaibhav.sahu?source=rss-166f47e53c4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*iPgrSFrjkde-Rxx8.</url>
            <title>Stories by Vaibhav Sahu on Medium</title>
            <link>https://medium.com/@vaibhav.sahu?source=rss-166f47e53c4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 20:03:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vaibhav.sahu/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[TypeScript Basic Types]]></title>
            <link>https://medium.com/@vaibhav.sahu/typescript-basic-types-370715eff1bc?source=rss-166f47e53c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/370715eff1bc</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[data-type]]></category>
            <dc:creator><![CDATA[Vaibhav Sahu]]></dc:creator>
            <pubDate>Sun, 22 Mar 2020 02:22:27 GMT</pubDate>
            <atom:updated>2020-03-22T02:22:27.222Z</atom:updated>
            <content:encoded><![CDATA[<h3>Boolean</h3><p>The most basic data type that holds only true/false values</p><pre><em>let isDone: boolean = false;</em></pre><h3>Number</h3><p>TypeScript numbers represent decimals or floating point numbers. It also supports binary, octal, and hexadecimal values.</p><pre>let decimal: number = 6;</pre><pre>let hex: number = 0xf00d;</pre><pre>let binary: number = 0b1010;</pre><pre>let octal: number = 0o744;</pre><pre>console.log(decimal);</pre><pre>console.log(hex.toString(16)); //print number in hex</pre><pre>console.log(binary.toString(2)); //print number in binary</pre><pre>console.log(octal.toString(8));//print number in octal</pre><h3>String</h3><p>String can be represented using double quotes “” or single quotes ‘’.</p><pre>let color: string = “blue”;</pre><pre>color = “red”;</pre><pre>console.log(color); //print red</pre><h3>Array</h3><p>TypeScript arrays behaves similar to JavaScript. There are two ways arrays can be written in two ways.</p><pre>let list: number[] = [1, 2, 3];</pre><pre>let list: Array&lt;number&gt; = [1, 2, 3];</pre><h3>Tuple</h3><pre>// Declare a tuple type</pre><pre>let x: [string, number];</pre><pre>// Initialize it</pre><pre>x = [“hello”, 10]; // OK</pre><h3>Enum</h3><p>Typescript provides names to numeric values through Enums.</p><pre>enum PrintMedia {</pre><pre>Newspaper = 1,</pre><pre>Newsletter,</pre><pre>Magazine,</pre><pre>Book</pre><pre>}</pre><pre>function getMedia(mediaName: string): PrintMedia {</pre><pre>if (  mediaName === &#39;Forbes&#39; || mediaName === &#39;Outlook&#39;) {</pre><pre>return PrintMedia.Magazine;</pre><pre>}</pre><pre>}</pre><pre>let mediaType: PrintMedia = getMedia(&#39;Forbes&#39;); // returns Magazine</pre><pre>console.log(mediaType);</pre><h3>Any</h3><p><strong>Any </strong>provides a convenient way to name a variable whose type is not known while writing the application or code.</p><pre>let notSure: any = 4;<br>notSure = &quot;maybe a string instead&quot;; <br>notSure = false; // okay, definitely a boolean</pre><pre>let list: any[] = [1, true, &quot;free&quot;];<br>list[1] = 100;</pre><h3>Void</h3><p>This can be used for function that do not return a value.</p><pre>function warnUser(): void { <br>    console.log(&quot;This is my warning message&quot;); <br>}</pre><pre>warnUser(); //print This is my warning message</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=370715eff1bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Global vs Local Var]]></title>
            <link>https://medium.com/@vaibhav.sahu/global-vs-local-var-a2b5f8d6758?source=rss-166f47e53c4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2b5f8d6758</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Vaibhav Sahu]]></dc:creator>
            <pubDate>Sat, 21 Mar 2020 04:04:40 GMT</pubDate>
            <atom:updated>2020-03-21T23:12:09.315Z</atom:updated>
            <content:encoded><![CDATA[<h3>Var vs Let</h3><p>Few examples related to <strong>var</strong></p><pre>var greeter: string= ‘Hello’;</pre><pre>function hello(): void {</pre><pre>//scoped local</pre><pre>var greeter:string = ‘hello’;</pre><pre>var local = ‘local’;</pre><pre>//local over global</pre><pre>console.log(greeter);</pre><pre>}</pre><pre>hello();</pre><pre>//global over local</pre><pre>console.log(greeter);</pre><pre>//local not accessible outside function block</pre><pre>console.log(local); //print undefined</pre><pre>Same variable using var can be defined multiples times</pre><pre>var greeter:string = ‘Hello’;</pre><pre>console.log(greeter); //print Hello</pre><pre>var greeter:string = ‘Bye’;</pre><pre>console.log(greeter); //print Bye</pre><pre>greeter = ‘greet again’;</pre><pre>console.log(greeter); //greet again</pre><p>Let’s talk about weird parts of JavaScript.</p><pre>var greeter = &quot;hey hi&quot;;<br>    var times = 4;<br><br>    if (times &gt; 3) {<br>        var greeter = &quot;say Hello instead&quot;; <br>    }</pre><pre>//since if condition returns true, and greeter would be //redefined, console would print &#39;say Hello instead&#39;<br>    console.log(greeter) //&quot;say Hello instead&quot;</pre><p>Few Examples related to <strong>Let</strong></p><p><strong>let</strong> is scoped to a block. it is not accessible outside block.</p><pre>let greeting = &quot;say Hi&quot;;<br>   let times = 4;<br><br>   if (times &gt; 3) {<br>        let hello = &quot;say Hello instead&quot;;<br>        console.log(hello);//&quot;say Hello instead&quot;<br>    }<br>   console.log(hello) // hello is not defined</pre><p><strong>let can be updated but not re-declared.</strong></p><pre>let greeting = &quot;say Hi&quot;;<br>    greeting = &quot;say Hello instead&quot;;//this won&#39;t generate any error</pre><pre>let greeting = &quot;say Hi&quot;;<br>    let greeting = &quot;say Hello instead&quot;;//this would give error //saying greeting has already been declared earlier</pre><p>Few examples related to <strong>const</strong>.</p><pre>const greeting = &quot;say Hi&quot;;<br>    greeting = &quot;say Hello instead&quot;;//error : Assignment to constant variable.</pre><pre>const greeting = &quot;say Hi&quot;;<br>    const greeting = &quot;say Hello instead&quot;;//error : Identifier &#39;greeting&#39; has already been declared</pre><pre>Objects declared using const can however be updated.</pre><pre>const greeting = {<br>        message : &quot;say Hi&quot;,<br>        times : 4<br>    }</pre><pre>greeting.spanish = &quot;Ola&quot;;</pre><pre>const greeting = {<br>        msg : &quot;say Hi&quot;<br>    } //error</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*9ubl2MVYGfvFy23NNJbuLg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2b5f8d6758" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>