<?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 Dilukshan Bimsara on Medium]]></title>
        <description><![CDATA[Stories by Dilukshan Bimsara on Medium]]></description>
        <link>https://medium.com/@dilukshanbimsara?source=rss-99339b9a4e6f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Wtm1xfY467NaGDTb7csr_w.jpeg</url>
            <title>Stories by Dilukshan Bimsara on Medium</title>
            <link>https://medium.com/@dilukshanbimsara?source=rss-99339b9a4e6f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 14:38:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dilukshanbimsara/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[Clean Code vs Quick-Fix Code: A Developer’s Dilemma]]></title>
            <link>https://medium.com/@dilukshanbimsara/clean-code-vs-quick-fix-code-a-developers-dilemma-f0dd72d27211?source=rss-99339b9a4e6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0dd72d27211</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[quickfix]]></category>
            <category><![CDATA[best-practices]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Dilukshan Bimsara]]></dc:creator>
            <pubDate>Mon, 08 Sep 2025 18:04:07 GMT</pubDate>
            <atom:updated>2025-09-08T18:04:07.337Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*LlorCVy3SyIxZMKRFkZ-Lw.jpeg" /></figure><p><strong>Imagine you walk into a kitchen.</strong></p><ol><li>One cook prepares meals in a <strong>clean, organized kitchen</strong>—every ingredient labeled, utensils in place, and waste cleared immediately.</li><li>Another cook prepares meals in a <strong>messy, rushed kitchen</strong>—ingredients scattered, no labels, dirty pans piling up.</li></ol><p>Both cooks serve you food. It might taste the same today, but which kitchen would you prefer to revisit tomorrow?</p><p>This is the <strong>same story with software development</strong>. Developers often face a choice between writing <strong>clean code</strong> or taking the shortcut with <strong>quick-fix code</strong>. Let’s break it down.</p><h3>What is clean code?</h3><p>Clean code is <strong>simple, clear, and maintainable</strong>. Other developers (or even your future self) can easily understand it without needing a long explanation.</p><h4>How to Identify Clean Code?</h4><ol><li>Names are <strong>meaningful</strong> (variables, functions, classes).</li><li>Functions are <strong>short</strong> and do <strong>one thing only</strong>.</li><li>Code is <strong>consistent</strong>, following style guides.</li><li>Comments are minimal because the code itself is self-explanatory.</li></ol><pre>function calculateDiscount(price: number, userType: &quot;regular&quot; | &quot;premium&quot;): number {<br>  const discountRates = {<br>    regular: 0.05,<br>    premium: 0.1,<br>  };<br><br>  return price - price * discountRates[userType];<br>}</pre><p>Above example: Easy to read, scalable if new user types are added.</p><h3>What is Quick-Fix Code?</h3><p>Quick-fix code is <strong>written fast to solve an immediate problem</strong> but often ignores readability, maintainability, or scalability.</p><h4>How to Identify Quick-Fix Code?</h4><ol><li>Hardcoded values.</li><li>Long confusing functions.</li><li>No clear separation of concerns.</li><li>Difficult for others to understand without explanations.</li></ol><pre>function calc(p: any, t: any): any {<br>  if (t === &quot;r&quot;) {<br>    return p - (p * 0.05);<br>  } else if (t === &quot;p&quot;) {<br>    return p - (p * 0.1);<br>  }<br>  return p;<br>}</pre><p>Above example: Works today, but confusing tomorrow.</p><h3>What Pushes Developers to Write Clean Code?</h3><ol><li><strong>Clear requirements</strong>: A well-defined user story.</li><li><strong>Sufficient timeline</strong>: Enough time to design properly.</li><li><strong>Good teamwork</strong>: Code reviews, pair programming.</li><li><strong>Company culture</strong>: Standards that value long-term quality.</li></ol><h4>Benefits of Clean Code</h4><ol><li>Easier to <strong>maintain and update</strong>.</li><li>Lower risk of bugs.</li><li>Improves <strong>team collaboration</strong>.</li><li>Code can survive and grow with the product.</li></ol><h4>Drawbacks of Clean Code</h4><ol><li>Takes <strong>more initial time</strong> to implement.</li><li>May feel <strong>slower</strong> in fast-paced environments.</li><li>Can be seen as <strong>over-engineering</strong> if requirements change suddenly.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*ADGz3uxRfzsre03oatAN8Q.jpeg" /></figure><h3>What Pushes Developers to Write Quick-Fix Code?</h3><ol><li><strong>Tight deadlines</strong>: “We need this in production today!”</li><li><strong>Unclear requirements</strong>: Lack of proper documentation.</li><li><strong>Pressure from management</strong>: Business value prioritized over quality.</li><li><strong>Bug fixes in emergency situations</strong>.</li></ol><h4>Benefits of Quick-Fix Code</h4><ol><li><strong>Fast delivery</strong>: Works well in emergencies.</li><li><strong>Business value delivered quickly</strong>.</li><li>Sometimes acceptable for <strong>temporary solutions</strong>.</li></ol><h4>Drawbacks of Quick-Fix Code</h4><ol><li>Hard to maintain later.</li><li>Increases <strong>technical debt</strong>.</li><li>Bugs multiply as code grows.</li><li>Frustrates future developers.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*cTHFBxa7710CkJ3wdhYKOQ.jpeg" /></figure><p>Clean code is like <strong>building a strong foundation</strong> for a house—it takes time but lasts decades.<br>Quick-fix code is like <strong>patching leaks with duct tape</strong>—it holds for now but fails tomorrow.</p><p>As developers, the art lies in knowing <strong>when to write clean code</strong> and <strong>when a quick fix is acceptable</strong>. Ideally, we should aim for clean code and use quick fixes only as a temporary bridge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0dd72d27211" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Client-Side Rendering vs Server-Side Rendeting (React)]]></title>
            <link>https://medium.com/@dilukshanbimsara/client-side-rendering-vs-server-side-rendeting-react-3899d3544220?source=rss-99339b9a4e6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3899d3544220</guid>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-js-performance]]></category>
            <dc:creator><![CDATA[Dilukshan Bimsara]]></dc:creator>
            <pubDate>Tue, 04 Feb 2025 14:49:36 GMT</pubDate>
            <atom:updated>2025-02-04T14:49:36.982Z</atom:updated>
            <content:encoded><![CDATA[<p>Codes : <a href="https://github.com/dilukshanbimsara/ServerSideRender.git">https://github.com/dilukshanbimsara/ServerSideRender.git</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jPBtZ_O9WitZhI5hYybylQ.png" /><figcaption>Client Side Rendering (As image, the web page creation process done by client side)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KI-Gy5AOs4y-4fjXUGCTNw.png" /><figcaption>Server Side Rendering (As image, prestructured html page provided by the server)</figcaption></figure><p><strong>Server-Side Rendering (SSR)</strong> in React is a technique where React components are rendered on the server and sent to the client as fully formed HTML. This improves performance and SEO, especially for content-heavy websites.</p><h3><strong>Use-cases of SSR</strong></h3><ol><li>Content-Heavy Websites</li></ol><p>Websites that feature a lot of content. Ex: Blogs, news sites, e-commerce platforms</p><p>2. Security-Sensitive Applications</p><p>Applications that handle sensitive data may benefit from SSR. (Rendering on the server helps mitigate risks associated with exposing JavaScript code to the client, thereby enhancing security.)</p><p>3. Initial Load Performance</p><p>For applications where initial load time is critical, such as e-commerce sites during sales events.</p><p>4. Users with Slow or Unreliable Internet Connections</p><p>Applications targeting users with limited bandwidth or slow connections can leverage SSR effectively. By offloading rendering tasks to the server, SSR minimizes the amount of data sent to the client and reduces loading times, enhancing the user experience even on poor networks.</p><p>5. Accessibility for Users with JavaScript Disabled</p><p>If the application needs to be accessible to users who may have JavaScript disabled or rely on assistive technologies.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3899d3544220" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction Promises]]></title>
            <link>https://medium.com/@dilukshanbimsara/introduction-promises-1c10089af0ff?source=rss-99339b9a4e6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c10089af0ff</guid>
            <category><![CDATA[promises]]></category>
            <category><![CDATA[js]]></category>
            <category><![CDATA[asynchronous]]></category>
            <dc:creator><![CDATA[Dilukshan Bimsara]]></dc:creator>
            <pubDate>Fri, 24 May 2024 16:16:13 GMT</pubDate>
            <atom:updated>2024-05-24T16:16:13.375Z</atom:updated>
            <content:encoded><![CDATA[<p>The sound of promises is the same as the normal meaning of a promise. It is a declaration or assurance that one will do something or that a particular thing will happen.</p><p>When it comes to programming, promises are a core feature for handling asynchronous operations. it shows a value that may be available now, in the future, or never.</p><p>In JavaScript, the promise maintains three states.</p><ol><li><strong>Pending </strong>: Initial state, and this represents that it’s still running.</li><li><strong>Fulfilled </strong>: The success state of the promise.</li><li><strong>Rejected </strong>: The failed or error states of the promise.</li></ol><p>Let&#39;s get an example:</p><p>Think you are supposed to have a vacation on the weekend. 1st you need to withdraw money from the bank, then, you go to the rental car shop and rent a car and finally you start journey.</p><p>lets simplify each steps:</p><ol><li>Withdraw money from bank.</li><li>Rent a car.</li><li>Start journey.</li></ol><p>Before starting your journey, you must complete two steps.</p><p><strong>A) Withdraw money from bank</strong></p><p>i. Pending : The time that is needed to process withdrawal process (account balance check, get money and reduce the withdrawn balance).</p><p>ii. Fulfilled : You successfully withdraw money.</p><p>iii. Rejected : You are unable to withdraw money (Not enough money in account, ATM machine problems, etc.)</p><p><strong>B) Rent a car</strong></p><p>i. Pending : The time that needs to be for get car</p><p>ii. Fulfilled : You successfully rent a car</p><p>iii. Rejected : You are unable to rent a car. (shop does not have car that you need, you don’t have valid document, etc.)</p><p><strong>C) Start journey</strong></p><p>To start journey we need to achieved above A and B steps in order with their Fulfilled status. So achieve this kind of scenarios we can use promises.</p><p><strong><em>Code implementation.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*kB7U_XdGaioDqZWNqY72zw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*GMsM1I92G39QSnNR1Z-CfQ.png" /></figure><h4><strong>How to combine these two promises together?</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*Laqm462WEcsekCYjwcDOtQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c10089af0ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Node.js]]></title>
            <link>https://medium.com/@dilukshanbimsara/why-node-js-ae52b08f357f?source=rss-99339b9a4e6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae52b08f357f</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Dilukshan Bimsara]]></dc:creator>
            <pubDate>Sun, 15 Oct 2023 18:16:11 GMT</pubDate>
            <atom:updated>2023-10-15T18:16:11.926Z</atom:updated>
            <content:encoded><![CDATA[<p>1. What is Node.js?</p><p>“Node.js is an <strong>open-source</strong> and <strong>cross-platform</strong> <strong>JavaScript runtime environment</strong>.” — <a href="https://nodejs.dev/en/learn/introduction-to-nodejs/">Ref</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*ukIAgupUp7OrwCe-axFWJA.png" /></figure><p>Open-source means that the source code for Node.js is publicly available and maintained by contributors from all over the world.</p><p>Before Node.js was released (2009), the only way to run JS code was using a browser. so it was only for the front-end. But if we have a runtime environment, we can run JS code without a browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*9rEa6nXJfRWUl0dzKv0ANw.png" /></figure><p><a href="https://en.wikipedia.org/wiki/Ryan_Dahl"><strong>Ryan Dahl</strong></a> created Node.js in 2009, and Google v8 Engine (the fastest JS engine) embedded it inside the C++ program.</p><p>Now we have a runtime environment, and we can build back-end applications using the same JavaScript programming language.</p><p>Cross-platform means that Node.js does not depend on any operating system. It can be used on any OS (linux, windows, Mac, etc.)</p><p>Node.js is fast, lightweight, scalable, No-buffering, etc. <strong>But it is not good for all kinds of systems.</strong></p><h3><strong>What kind of scenario does Node.js best? 😎</strong></h3><p><strong>Event-driven (</strong><em>JS also runs event-wise.)</em></p><p><strong>Data-intensive (</strong><em> The usually need to Store, read, and update Data in data source</em><strong>)</strong></p><p><strong>I/O-intensive </strong>( <em>Usually get input and show output in real time, ex: Chat app</em>)</p><p><strong>Non-Blocking</strong> (<em>There is no big Data processing in business logic </em>)</p><h3>What kind of scenario does Node.js not best? 😕</h3><p><strong>Much Data calculation (</strong><em>Find</em><strong> </strong><em>the </em>standard deviation <em>of big data set</em><strong>)</strong></p><p><strong>CPU-intensive, also known as process-intensive </strong>( <em>Most of Scientific computing, these rarely depend on IO and spend long periods processing the data before producing the result at the end. </em>)</p><p><strong>Blocking Operations </strong>( <em>The middle of process is important to end result and until it is done, the other operations have to be blocked.</em>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae52b08f357f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get content from HTML/XML as plain text]]></title>
            <link>https://medium.com/@dilukshanbimsara/get-content-from-html-xml-as-plain-text-e7747cc0724d?source=rss-99339b9a4e6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7747cc0724d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[domparse]]></category>
            <category><![CDATA[ht]]></category>
            <category><![CDATA[get-content-from-html]]></category>
            <dc:creator><![CDATA[Dilukshan Bimsara]]></dc:creator>
            <pubDate>Fri, 13 Oct 2023 19:04:24 GMT</pubDate>
            <atom:updated>2023-10-13T19:04:24.916Z</atom:updated>
            <content:encoded><![CDATA[<p>Example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x3_TJ8bY5nwoqUhoA_3YRA.png" /></figure><pre>const htmlInput = &#39;&lt;h1&gt;This is h1&lt;/h1&gt;&lt;p&gt;sample one&lt;/p&gt;&lt;p&gt;&lt;strong&gt;bold text&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;italic&lt;/em&gt;&lt;/p&gt;&#39;<br>const parser = new DOMParser()<br>const decodedHTML = parser.parseFromString(htmlInput, &#39;text/html&#39;).documentElement.textContent<br>// decodeHTML valueis &#39;This is h1sample onebold textitalic&#39;</pre><p>As in the above example, first we create an instance of DOMParser(). DOMParser is a native JavaScript constructor.(DOM : Document Object Model. The DOM represents the document as nodes and objects; that way, programming languages can interact with the page.)</p><p>This DOMParser object can be used to parse the text of a document using the parseFromString() method. parseFromString() function get 2 parameters.</p><p><strong>parseFromString</strong>(<strong>string</strong>: string, <strong>type</strong>: DOMParserSupportedType)</p><pre>parseFromString(string: string, type: DOMParserSupportedType)<br>//this function return Docuent object<br>//to access text content we use documentElement.textContent<br><br>const data = parseFromString(string: string, type: DOMParserSupportedType).documentElement.textContent</pre><pre>function reverseHTML(htmlInput: string) {<br>  const parser = new DOMParser()<br>  const decodedHTML = parser.parseFromString(htmlInput, &#39;text/html&#39;).documentElement.textContent<br>  return decodedHTML<br>}<br><br>const textWithHTMLTag = &#39;&lt;h1&gt;This is h1&lt;/h1&gt;&lt;p&gt;sample one&lt;/p&gt;&lt;p&gt;&lt;strong&gt;bold text&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;em&gt;italic&lt;/em&gt;&lt;/p&gt;&#39;<br><br>const plainText = reverseHTML(textWithHTMLTag)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7747cc0724d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Closures in JavaScript]]></title>
            <link>https://medium.com/@dilukshanbimsara/closures-in-javascript-2ae6ac037718?source=rss-99339b9a4e6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ae6ac037718</guid>
            <category><![CDATA[function]]></category>
            <category><![CDATA[scope-variables]]></category>
            <category><![CDATA[closure-in-javascript]]></category>
            <dc:creator><![CDATA[Dilukshan Bimsara]]></dc:creator>
            <pubDate>Wed, 04 Oct 2023 19:38:02 GMT</pubDate>
            <atom:updated>2023-10-04T19:38:02.316Z</atom:updated>
            <content:encoded><![CDATA[<p>What are closures?</p><p><strong><em>Closure means that an inner function always has access to the vars and parameters of its outer function, even after the outer function has returned.</em></strong><em> (from tutorialsteacher.com)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*6lX07t7QizGcI8qn8PhiTg.png" /></figure><p>Let&#39;s see how local and global variables access and change their values from inside functions.</p><pre>//global scope variable<br>let global = 1;<br><br>const parentFunction = () =&gt; {<br>    //local scope variable<br>    let local = 5;<br>    <br>    console.log(global);<br>    console.log(local);<br>    <br>    const childFunction = () =&gt; {<br>        console.log(global += 1);<br>        console.log(local += 1);<br>    }<br>    <br>    childFunction();<br>    console.log(&#39;after child function call : &#39;+ local);<br>}<br><br>parentFunction()<br>console.log(&#39;After function call : &#39; + global);<br><br>/*<br>The result would be<br>1<br>5<br>2<br>6<br>after child function call : 6<br>After function call : 2<br>*/</pre><p>In the above example, “<strong>childFunction</strong>” can access the outer function (‘<strong>parentFunction</strong>’) variable (‘<strong>local</strong>’) even if it is declared outside of the inner function (‘<strong>childFunction</strong>’).</p><p>If we need access to the “local” variable from outside of &quot;parentFunction” we can simply return the child function from the parent function.</p><pre>//global scope variable<br>let global = 1;<br><br>const parentFunction = () =&gt; {<br>    //local scope variable<br>    let local = 5;<br>    <br>    console.log(global);<br>    console.log(local);<br>    <br>    const childFunction = () =&gt; {<br>        console.log(global += 1);<br>        console.log(local += 1);<br>    }<br>    <br>    return childFunction;<br>}<br><br>const result = parentFunction();<br><br>console.log(result)<br>result();<br>result();<br><br>console.log(&#39;global variable after function calls : &#39; + global)<br><br>/*<br>The results would be<br>1<br>5<br>[Function: childFunction]<br>2<br>6<br>3<br>7<br>global variable after function calls : 3<br>*/</pre><p>As you can see, when we call inner functions from outside the parent and child functions, both local and global variables can change. but still we cannot access the local variable directly from outside the scope.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ae6ac037718" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[‘type’ And ‘interface’ In TypeScript]]></title>
            <link>https://medium.com/@dilukshanbimsara/type-and-interface-in-typescript-cf0a8388eaa3?source=rss-99339b9a4e6f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf0a8388eaa3</guid>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Dilukshan Bimsara]]></dc:creator>
            <pubDate>Wed, 16 Aug 2023 16:14:51 GMT</pubDate>
            <atom:updated>2023-08-16T16:14:51.712Z</atom:updated>
            <content:encoded><![CDATA[<p>When we deal with data, we have to use data types. Maybe it can be simple/basic data types (int, char, etc.) or custom data types (which means user-created types). In TypeScript, <strong>type</strong> and <strong>interface</strong> are used to define custom data structures, contracts, or shapes.</p><ol><li><strong>type</strong></li></ol><p>The ‘<strong>type</strong>’ keyword in TypeScript is used to create custom type aliases. It use existing data types to create complex types.</p><pre>//Create vehicle data type<br>type Vehicle = {<br>  year: number<br>  type: string<br>  model: string<br>}<br><br>//Create car object using vehicle data type<br>const car:Vehicle = {<br>  year: 2012,<br>  type: &#39;Toyota&#39;,<br>  model: &#39;Corolla&#39;<br>}</pre><p>type can also be used to create advanced types like unions and intersections.</p><pre>// Here we can use only &#39;active&#39;, &#39;inactive&#39;, or &#39;pending&#39; for type Status<br>type Status = &#39;active&#39;|&#39;pending&#39;|&#39;inactive&#39;<br><br>type DropdownDataList = {<br>  text: string<br>  value: string<br>  id: string<br>}<br><br>type FilterFormFields = {<br>  time: number<br>//Below dateRange we can use only Date type or null array (array length=2)<br>  dateRange: [Date | null, Date | null]<br>  type: DropdownDataList<br>  group: DropdownDataList<br>  agency: DropdownDataList<br>}</pre><p><strong>2. interface</strong></p><p>The ‘<strong>interface</strong>’ keyword is used to define object shapes. It specifies the structure that an object should follow. It can include properties, methods, and other member details.</p><pre>//Create interface As User<br>interface User {<br>  name: string<br>  age: number<br>  nic: string<br>}<br><br>//Create person object using User interface<br>const person: User = {<br>  name: &#39;bimsara&#39;<br>  age: 24<br>  nic: &#39;199936012025&#39;<br>}<br><br>//Create employee interface extend from User <br>interface Employee extends User {<br>  //User interface properties already therewhen we extend from User<br>  employeeId: string<br>  designation: string<br>}<br><br>//Create employee object using Employee interface<br>const employee: Employee = {<br>  name: &#39;Bimsara&#39;<br>  age: 24,<br>  employeeId: &#39;Emp-12345&#39;,<br>  designation: &quot;Software Developer&quot;<br>}</pre><p>Resume:</p><p>‘<strong>type</strong>’ can create unions, intersections, and mapped types.</p><p>‘<strong>interface</strong>’ can extend other interfaces to inherit members.</p><p>In most cases, ‘<strong>interfaces’</strong> are better when specifying the structure of objects, especially when using them together in classes or making use of declaration merging. ‘<strong>type’</strong> is more flexible for generating complicated type compositions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf0a8388eaa3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>