<?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 Azat Nobatov on Medium]]></title>
        <description><![CDATA[Stories by Azat Nobatov on Medium]]></description>
        <link>https://medium.com/@azatprog?source=rss-793cb237c7dd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*LJiHEuHnZ2V8A6Ksw6z7Pw.jpeg</url>
            <title>Stories by Azat Nobatov on Medium</title>
            <link>https://medium.com/@azatprog?source=rss-793cb237c7dd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 08:56:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@azatprog/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[Dream features in New Typescript 3.7 are coming: Optional Chaining and Nullish Coalescing]]></title>
            <link>https://medium.com/@azatprog/dream-features-in-new-typescript-3-7-are-coming-optional-chaining-and-nullish-coalescing-185b2e2c41e6?source=rss-793cb237c7dd------2</link>
            <guid isPermaLink="false">https://medium.com/p/185b2e2c41e6</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Azat Nobatov]]></dc:creator>
            <pubDate>Wed, 02 Oct 2019 21:57:48 GMT</pubDate>
            <atom:updated>2019-10-09T15:33:01.596Z</atom:updated>
            <content:encoded><![CDATA[<p>TypeScript 3.7 is in Beta version, however, if you want to check it out you can install via npm:</p><pre>npm install typescript@beta</pre><h4>1. Optional Chaining</h4><p>Let’s assume we have an object <strong><em>car</em></strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e440da6cb385904cce8aaa9c563f931/href">https://medium.com/media/8e440da6cb385904cce8aaa9c563f931/href</a></iframe><p>Also, we want to check if the sale property contains a value then do something. Most likely we would have written such <strong><em>if</em></strong> condition:</p><pre>if (car &amp;&amp; car.price &amp;&amp; car.price.sale) {  <br>  //...<br>}</pre><p>Now, with <strong><em>optional chaining </em></strong>we can do as follows:</p><pre>if (car?.price?.sale) {<br>  //...<br>}</pre><p>So, what is the <strong>?.<em> </em></strong><em>operator</em>?</p><p>In <strong>optional chaining </strong>the <strong>?. </strong>operator allows us to stop some expressions whenever we find <strong>null</strong> or <strong>undefined</strong>.</p><p>Or with <strong><em>ternary operators</em></strong>:</p><pre>const salePrice = (car &amp;&amp; car.price &amp;&amp; car.price.sale) <br>                       ? car.price.sale <br>                       : undefined;</pre><p>However, with <strong>?. <em>optional chaining</em> </strong>operator it is as easy as follows:</p><pre>const salePrice = car?.price?.sale;</pre><p>Basically, it immediately stops the expression when a property of the object equals to <strong>null</strong> or <strong>undefined</strong>.</p><h4>2. Nullish Coalescing</h4><p>Let’s suppose we want to check for sale price if it is available then use it otherwise get the price from by calling some function. We would write the code like:</p><pre>const price = (salePrice !== null  || salePrice !== undefined)<br>                 ? salePrice <br>                 : getSalePrice();</pre><p>However, the <strong><em>nullish coalescing</em></strong><em> operator allows us to make it much simpler:</em></p><pre>const price = salePrice ?? getSalePrice();</pre><p>Basically, it says use <strong><em>salePrice</em></strong> if it is available otherwise call <strong><em>getSalePrice()</em></strong> function. It is quite simple, isn’t it? :)</p><p>This is my first blog, despite my 7+ years of experience in web development, I never had a chance to write a blog -_-</p><p>I hope you found it useful… If you like it, give a clap or claps ;)</p><figure><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_image"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PYxBP_WV7LI6zc-zdUkNqQ.png" /></a></figure><p>📝 Read this story later in <a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text">Journal</a>.</p><p>👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. <a href="https://usejournal.com/newsletter/noteworthy-in-tech/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_text">Read the Noteworthy in Tech newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=185b2e2c41e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>