<?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: Nguyen Trong Duc Luong</title>
    <description>The latest articles on Forem by Nguyen Trong Duc Luong (@a_vietnamese_guy).</description>
    <link>https://forem.com/a_vietnamese_guy</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%2F356158%2Ff41274d2-1835-4ae3-9d4b-8809bc68bce0.png</url>
      <title>Forem: Nguyen Trong Duc Luong</title>
      <link>https://forem.com/a_vietnamese_guy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/a_vietnamese_guy"/>
    <language>en</language>
    <item>
      <title>Conditionally rendering in React with ternary operator</title>
      <dc:creator>Nguyen Trong Duc Luong</dc:creator>
      <pubDate>Fri, 28 Aug 2020 03:58:36 +0000</pubDate>
      <link>https://forem.com/a_vietnamese_guy/conditionally-rendering-in-react-with-ternary-operator-2n32</link>
      <guid>https://forem.com/a_vietnamese_guy/conditionally-rendering-in-react-with-ternary-operator-2n32</guid>
      <description>&lt;p&gt;This is a common technique when you want to render one out of two components based on a condition (for example when a state or a prop changes). If you have multiple conditions i advise you to use &lt;code&gt;switch&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In the below example, you can change the greeting text by clicking the button which will change the state of &lt;code&gt;buttonClicked&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/sparkling-bird-wi7e3?file=/src/App.js"&gt;Link to the live demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4p2T-0hO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sdo9l4pjauq7l2l80u2b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4p2T-0hO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sdo9l4pjauq7l2l80u2b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>What are immediately invoked function expressions (IIFEs) ?</title>
      <dc:creator>Nguyen Trong Duc Luong</dc:creator>
      <pubDate>Wed, 19 Aug 2020 09:26:44 +0000</pubDate>
      <link>https://forem.com/a_vietnamese_guy/what-are-immediately-invoked-function-expressions-iifes-15mi</link>
      <guid>https://forem.com/a_vietnamese_guy/what-are-immediately-invoked-function-expressions-iifes-15mi</guid>
      <description>&lt;p&gt;In Javascript it is possible for a function to call itself when it is defined. This technique is called immediately invoked function expression (abbreviated IIFE), though it sounds like the definition of recursion but its main purpose is to encapsulate modules (this was a popular technique before ES6).&lt;/p&gt;

&lt;p&gt;See the below example to have a better understanding&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var counter = (function () {
  var num = 0;

  function increaseNumber() {
    num++;
  }

  function decreaseNumber() {
    num--;
  }

  return {
    getNum: function () {
      return num;
    },

    inc: increaseNumber,
    dec: decreaseNumber,
  };
})();

// the inital value of num is 0
console.log(counter.getNum());

counter.inc(); // num is 1
counter.inc(); // num is 2
counter.inc(); // num is 3

// this technique gives you the ability to hide 
// state inside the function closure
console.log(counter.getNum());

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



&lt;p&gt;Reference book:&lt;br&gt;
&lt;em&gt;Programming Javascript applications of Eric Elliot&lt;/em&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
