<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Operators - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Operators - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Tue, 23 Jun 2026 22:45:21 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/operators/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Use the Greater Than and Less Than Operators in JavaScript ]]>
                </title>
                <description>
                    <![CDATA[ In your JavaScript programs, you'll often need to compare two values to see if one is greater than or less than the other. This is where the greater than and less than operators come in handy. In this article, we'll look at how to use these operators... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/greater-than-and-less-than-operators-in-js/</link>
                <guid isPermaLink="false">66b8d9538cd1c2aa053d49b0</guid>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Operators ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Jessica Wilkins ]]>
                </dc:creator>
                <pubDate>Tue, 13 Feb 2024 11:02:26 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/02/pexels-pixabay-417173--3-.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In your JavaScript programs, you'll often need to compare two values to see if one is greater than or less than the other. This is where the greater than and less than operators come in handy.</p>
<p>In this article, we'll look at how to use these operators in greater detail through code examples.</p>
<h2 id="heading-how-to-use-the-greater-than-gt-operator-in-javascript">How to Use the Greater Than <code>&gt;</code> Operator in JavaScript</h2>
<p>You can use the greater than operator to check if the value on the left is greater than the value on the right. It is represented by the <code>&gt;</code> symbol.</p>
<p>The result will return a Boolean value of <code>true</code> if the value on the left is greater than the value on the right, and <code>false</code> if it is not.</p>
<p>Here is an example of checking if <code>5</code> is greater than <code>3</code>:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> &gt; <span class="hljs-number">3</span>); <span class="hljs-comment">// true</span>
</code></pre>
<p>Since the number <code>5</code> is greater than <code>3</code>, the result will be <code>true</code>.</p>
<p>If we switch the two values, then the result will be <code>false</code>:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">3</span> &gt; <span class="hljs-number">5</span>); <span class="hljs-comment">// false</span>
</code></pre>
<h2 id="heading-how-to-use-the-less-than-lt-operator-in-javascript">How to Use the Less Than <code>&lt;</code> Operator in JavaScript</h2>
<p>You can use the less than operator to check if the value on the left is less than the value on the right. It is represented by the <code>&lt;</code> symbol.</p>
<p>The result will return a Boolean value of <code>true</code> if the value on the left is less than the value on the right, and <code>false</code> if it is not.</p>
<p>Here is an example that checks if the number <code>3</code> is less than <code>5</code>:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">3</span> &lt; <span class="hljs-number">5</span>); <span class="hljs-comment">// true</span>
</code></pre>
<p>Since <code>3</code> is less than <code>5</code>, the result will be <code>true</code>.</p>
<p>But if we switch the two values, then the result will be <code>false</code>:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> &lt; <span class="hljs-number">3</span>); <span class="hljs-comment">// false</span>
</code></pre>
<h2 id="heading-how-to-use-the-greater-than-or-equal-to-gt-operator-in-javascript">How to Use the Greater Than or Equal To <code>&gt;=</code> Operator in JavaScript</h2>
<p>If you need to check if the value on the left is greater than or equal to the value on the right, you can use the greater than or equal to operator. It is represented by the <code>&gt;=</code> symbol.</p>
<p>The result will return a Boolean value of <code>true</code> if the value on the left is greater than or equal to the value on the right, and <code>false</code> if it is not.</p>
<p>Here is an example of that checks if the number <code>5</code> is greater than or equal to <code>5</code>:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> &gt;= <span class="hljs-number">5</span>); <span class="hljs-comment">// true</span>
</code></pre>
<p>Since the number <code>5</code> is equal to <code>5</code>, the result will be <code>true</code>.</p>
<p>If we change the left value to be the number <code>3</code>, then the result will be <code>false</code>:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">3</span> &gt;= <span class="hljs-number">5</span>); <span class="hljs-comment">// false</span>
</code></pre>
<h2 id="heading-how-to-use-the-less-than-or-equal-to-lt-operator-in-javascript">How to Use the Less Than or Equal To <code>&lt;=</code> Operator in JavaScript</h2>
<p>If you need to check if the value on the left is less than or equal to the value on the right, you can use the less than or equal to operator. It is represented by the <code>&lt;=</code> symbol.</p>
<p>The result will return a Boolean value of <code>true</code> if the value on the left is less than or equal to the value on the right, and <code>false</code> if it is not.</p>
<p>Here is an example of that checks if the number <code>3</code> is less than or equal to <code>5</code>:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">3</span> &lt;= <span class="hljs-number">5</span>); <span class="hljs-comment">// true</span>
</code></pre>
<p>If we change the left value to be the number <code>6</code>, then the result will be <code>false</code>:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">6</span> &lt;= <span class="hljs-number">5</span>); <span class="hljs-comment">// false</span>
</code></pre>
<h2 id="heading-how-to-use-comparison-operators-in-a-conditional-statement">How to Use Comparison Operators in a Conditional Statement</h2>
<p>It is common to use comparison operators inside conditional statements like an <code>if</code> statement.</p>
<p>In this example, we have an application that asks the user for their age and displays a response based on the age they entered:</p>
<p>For the HTML, we'll use a form to ask the user for their age. Below the form, we'll display the message based on the age entered.</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"title"</span>&gt;</span>How old are you?<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"form"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"input-container"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"age"</span>&gt;</span>Enter your age: <span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"number"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"age"</span> <span class="hljs-attr">required</span> <span class="hljs-attr">min</span>=<span class="hljs-string">"1"</span> <span class="hljs-attr">max</span>=<span class="hljs-string">"120"</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"submit-btn"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"submit-btn"</span>&gt;</span>Submit age<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>

  <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"result-para"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"result"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
</code></pre>
<p>Next, we'll use a method called <code>getElementById</code> to go through the HTML document to find the elements that match the ids we specify. </p>
<p>We can use the method to get the form element, age input and result paragraph, and assign them to <code>const</code> variables:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> ageInput = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"age"</span>);
<span class="hljs-keyword">const</span> form = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"form"</span>);
<span class="hljs-keyword">const</span> resultParagraph = <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"result"</span>);
</code></pre>
<p>We then want to create an array of strings to show the user based on their age.</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> responsesArr = [
  <span class="hljs-string">"Oh wow! You are just a kid."</span>,
  <span class="hljs-string">"Nice! It looks like you are old enough to drive in the States."</span>,
  <span class="hljs-string">"Awesome! It looks like you are old enough to vote in the States."</span>,
  <span class="hljs-string">"Cool! It looks like you are old enough to drink in the States."</span>,
];
</code></pre>
<p>Then we need to create a function called <code>displayResponse</code> with a parameter called <code>age</code>. This function will be responsible for displaying the messages based on the age entered.</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">displayResponse</span>(<span class="hljs-params">age</span>) </span>{

}
</code></pre>
<p>Inside that function, we need to check if the user's age is less than <code>16</code>. If it is, we'll display the first message in the <code>responsesArr</code> array.</p>
<p>We'll use the <code>textContent</code> property to change the text inside the <code>resultParagraph</code> element.</p>
<pre><code class="lang-js"><span class="hljs-keyword">if</span> (age &lt; <span class="hljs-number">16</span>) {
  resultParagraph.textContent = responsesArr[<span class="hljs-number">0</span>];
}
</code></pre>
<p>If the user is between <code>16</code> and <code>18</code>, we will display the second message in the <code>responsesArr</code> array.</p>
<pre><code class="lang-js"><span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (age &gt;= <span class="hljs-number">16</span> &amp;&amp; age &lt; <span class="hljs-number">18</span>) {
    resultParagraph.textContent = responsesArr[<span class="hljs-number">1</span>];
  }
</code></pre>
<p>If the user is between <code>18</code> and <code>21</code>, we will display the third message in the <code>responsesArr</code> array.</p>
<pre><code class="lang-js"><span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (age &gt;= <span class="hljs-number">18</span> &amp;&amp; age &lt; <span class="hljs-number">21</span>) {
    resultParagraph.textContent = responsesArr[<span class="hljs-number">2</span>];
}
</code></pre>
<p>If the user is <code>21</code> or older, we will display the last message in the <code>responsesArr</code> array.</p>
<pre><code class="lang-js"><span class="hljs-keyword">else</span> {
    resultParagraph.textContent = responsesArr[<span class="hljs-number">3</span>];
  }
</code></pre>
<p>The last part of this function is to reset the form after the user submits their age.</p>
<pre><code class="lang-js">ageInput.value = <span class="hljs-string">""</span>;
</code></pre>
<p>Here is the complete function:</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">displayResponse</span>(<span class="hljs-params">age</span>) </span>{
  <span class="hljs-keyword">if</span> (age &lt; <span class="hljs-number">16</span>) {
    resultParagraph.textContent = responsesArr[<span class="hljs-number">0</span>];
  } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (age &gt;= <span class="hljs-number">16</span> &amp;&amp; age &lt; <span class="hljs-number">18</span>) {
    resultParagraph.textContent = responsesArr[<span class="hljs-number">1</span>];
  } <span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span> (age &gt;= <span class="hljs-number">18</span> &amp;&amp; age &lt; <span class="hljs-number">21</span>) {
    resultParagraph.textContent = responsesArr[<span class="hljs-number">2</span>];
  } <span class="hljs-keyword">else</span> {
    resultParagraph.textContent = responsesArr[<span class="hljs-number">3</span>];
  }
  ageInput.value = <span class="hljs-string">""</span>;
}
</code></pre>
<p>The last part of this application is to add an event listener that checks when the user submits their input into the form, and display that message based on the age entered.</p>
<p>We are going to use the <code>addEventListener</code> method to listen for the <code>submit</code> event on the form. When the form is submitted, we will prevent the default behavior of the form and call the <code>displayResponse</code> function with the value of the age input.</p>
<pre><code class="lang-js">form.addEventListener(<span class="hljs-string">"submit"</span>, <span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> {
  e.preventDefault();
  displayResponse(ageInput.value);
});
</code></pre>
<p>Here is a complete interactive example on CodePen:</p>
<div class="embed-wrapper">
        <iframe width="100%" height="350" src="https://codepen.io/Jessica-Wilkins-the-flexboxer/embed/zYbMBaP" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="CodePen embed" scrolling="no" allowtransparency="true" allowfullscreen="true" loading="lazy"></iframe></div>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Working with comparison operators like the greater than, greater than or equal to, less than and less than or equal to operators is a common task in JavaScript. They are used to compare two values and return a Boolean value of <code>true</code> or <code>false</code> based on the comparison.</p>
<p>I hope you enjoyed this article and found it helpful.</p>
<p>Happy coding!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How Does Short-Circuiting Work in JavaScript? ]]>
                </title>
                <description>
                    <![CDATA[ In JavaScript, understanding truthy and falsy values is fundamental to writing efficient and concise code. Combined with the concept of short-circuiting, developers can write elegant solutions to common programming challenges.  In this hands-on guide... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/short-circuiting-in-javascript/</link>
                <guid isPermaLink="false">66bb882f7a6500a14ba5b75c</guid>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Operators ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Sahil ]]>
                </dc:creator>
                <pubDate>Mon, 12 Feb 2024 18:38:38 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/02/Copy-of-Neon-Green-Bold-Quote-Motivational-Tweet-Instagram-Post-3-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In JavaScript, understanding truthy and falsy values is fundamental to writing efficient and concise code. Combined with the concept of short-circuiting, developers can write elegant solutions to common programming challenges. </p>
<p>In this hands-on guide, we'll explore truthy and falsy values, and understand the mechanics of short-circuiting in JavaScript.</p>
<p>You can get all the source code from <a target="_blank" href="https://github.com/dotslashbit/fcc-article-resources/blob/main/javascript-short-circuiting/index.js">here</a>.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><a class="post-section-overview" href="#heading-understanding-truthy-and-falsy-values">Understanding Truthy and Falsy Values</a></li>
<li><a class="post-section-overview" href="#heading-what-is-short-circuiting-in-javascript">What is Short-Circuiting in JavaScript?</a></li>
<li><a class="post-section-overview" href="#heading-practical-use-cases">Practical Use Cases</a></li>
<li><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></li>
</ul>
<h2 id="heading-understanding-truthy-and-falsy-values">Understanding Truthy and Falsy Values</h2>
<p>In JavaScript, every value has an inherent Boolean interpretation when evaluated in a Boolean context. Values that evaluate to <code>true</code> are considered truthy, while that evaluate to <code>false</code> are falsy. </p>
<p>Let's explore some examples:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Truthy Values</span>
<span class="hljs-keyword">if</span> (<span class="hljs-string">'Hello'</span>) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Truthy!'</span>); <span class="hljs-comment">// Output: Truthy!</span>
}

<span class="hljs-keyword">if</span> (<span class="hljs-number">42</span>) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Truthy!'</span>); <span class="hljs-comment">// Output: Truthy!</span>
}

<span class="hljs-keyword">if</span> ([<span class="hljs-string">'apple'</span>, <span class="hljs-string">'banana'</span>]) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Truthy!'</span>); <span class="hljs-comment">// Output: Truthy!</span>
}

<span class="hljs-comment">// Falsy Values</span>
<span class="hljs-keyword">if</span> (<span class="hljs-string">''</span>) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Falsy!'</span>); <span class="hljs-comment">// This code block is not executed</span>
}

<span class="hljs-keyword">if</span> (<span class="hljs-number">0</span>) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Falsy!'</span>); <span class="hljs-comment">// This code block is not executed</span>
}

<span class="hljs-keyword">if</span> (<span class="hljs-literal">null</span>) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Falsy!'</span>); <span class="hljs-comment">// This code block is not executed</span>
}
</code></pre>
<p>Here's a breakdown of the code above:</p>
<h3 id="heading-truthy-values">Truthy Values</h3>
<ul>
<li><code>'Hello'</code>: Any non-empty string in JavaScript is considered truthy. In this case, the string <code>'Hello'</code> is non-empty, so the condition evaluates to true.</li>
<li><code>42</code>: Any non-zero number (positive or negative) is considered truthy. Since <code>42</code> is a non-zero number, the condition evaluates to true.</li>
<li><code>['apple', 'banana']</code>: Arrays in JavaScript are considered truthy, regardless of their contents. Since the array <code>['apple', 'banana']</code> is non-empty, the condition evaluates to true.</li>
</ul>
<h3 id="heading-falsy-values">Falsy Values</h3>
<p><code>''</code> (empty string): An empty string in JavaScript is considered falsy. Therefore, the condition evaluates to false, and the code block inside the if statement will not be executed.</p>
<p><code>0</code>: The number zero is considered falsy in JavaScript. Therefore, the condition evaluates to false, and the code block inside the if statement will not be executed.</p>
<p><code>null</code>: The null value is considered falsy in JavaScript. Therefore, the condition evaluates to false, and the code block inside the if statement will not be executed.</p>
<p>In JavaScript, values other than <code>false</code>, <code>0</code>, <code>''</code> (empty string), <code>null</code>, <code>undefined</code>, and <code>NaN</code> are considered truthy. Understanding these truthy and falsy values is crucial when writing conditional statements and logical operations in JavaScript.</p>
<p>Understanding truthy and falsy values is crucial as they play a significant role in conditional statements and logical operations.</p>
<h2 id="heading-what-is-short-circuiting-in-javascript">What is Short-Circuiting in JavaScript?</h2>
<p>Short-circuiting is a behavior exhibited by logical operators (<code>&amp;&amp;</code>, <code>||</code>) where the evaluation of the second operand is skipped if the outcome can be determined by evaluating the first operand alone. </p>
<p>Let's examine how short-circuiting works with practical examples:</p>
<h3 id="heading-the-ampamp-operator">The <code>&amp;&amp;</code> Operator</h3>
<p>The <code>&amp;&amp;</code> operator returns the first falsy operand, or the last truthy operand if all operands are truthy.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> value = <span class="hljs-number">0</span>;
<span class="hljs-keyword">const</span> result = value &amp;&amp; <span class="hljs-string">'Truthy Value'</span>;
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// Output: 0</span>
</code></pre>
<p>In this example, <code>value</code> evaluates to <code>0</code>, which is a falsy value. Since the first operand is falsy, the expression short-circuits, and the result is <code>0</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> value = <span class="hljs-string">'Hello'</span>;
<span class="hljs-keyword">const</span> result = value &amp;&amp; <span class="hljs-string">'Truthy Value'</span>;
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// Output: Truthy Value</span>
</code></pre>
<p>Here, <code>value</code> evaluates to a non-empty string, which is truthy. Therefore, the second operand <code>'Truthy Value'</code> is returned, as it's the last truthy operand.</p>
<h3 id="heading-the-operator">The <code>||</code> Operator</h3>
<p>The <code>||</code> operator returns the first truthy operand, or the last falsy operand if all operands are falsy.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> name = <span class="hljs-string">''</span>;
<span class="hljs-keyword">const</span> displayName = name || <span class="hljs-string">'Guest'</span>;
<span class="hljs-built_in">console</span>.log(displayName); <span class="hljs-comment">// Output: Guest</span>
</code></pre>
<p>In this example, <code>name</code> evaluates to an empty string, which is falsy. Therefore, the expression short-circuits, and <code>'Guest'</code> is assigned to <code>displayName</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> name = <span class="hljs-string">'Alice'</span>;
<span class="hljs-keyword">const</span> displayName = name || <span class="hljs-string">'Guest'</span>;
<span class="hljs-built_in">console</span>.log(displayName); <span class="hljs-comment">// Output: Alice</span>
</code></pre>
<p>Here, <code>name</code> evaluates to a non-empty string, which is truthy. Therefore, the first operand <code>'Alice'</code> is returned, as it's the first truthy operand encountered.</p>
<h2 id="heading-practical-use-cases">Practical Use Cases</h2>
<h3 id="heading-providing-default-values">Providing Default Values</h3>
<p>Short-circuiting is commonly used to provide default values for variables.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> options = {};
<span class="hljs-keyword">const</span> limit = options.limit || <span class="hljs-number">10</span>;
<span class="hljs-built_in">console</span>.log(limit); <span class="hljs-comment">// Output: 10 (default value)</span>
</code></pre>
<p>In this example, <code>options</code> is an empty object. The code intends to assign a value to <code>limit</code> based on the <code>options.limit</code> property. However, since <code>options.limit</code> is not defined (it's undefined), the logical OR (<code>||</code>) operator is used.</p>
<p>The logical OR operator returns the value of the first operand if it's truthy. If the first operand is falsy (in this case, <code>options.limit</code> is undefined), it returns the value of the second operand (<code>10</code> in this case), which acts as a default value.</p>
<p>Therefore, <code>limit</code> will be assigned the value <code>10</code> because <code>options.limit</code> is falsy (undefined).</p>
<h3 id="heading-safely-accessing-nested-properties">Safely Accessing Nested Properties</h3>
<p>Short-circuiting can also be used to safely access nested properties of objects.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> user = { <span class="hljs-attr">address</span>: { <span class="hljs-attr">city</span>: <span class="hljs-string">'New York'</span> } };
<span class="hljs-keyword">const</span> city = user.address &amp;&amp; user.address.city;
<span class="hljs-built_in">console</span>.log(city); <span class="hljs-comment">// Output: New York</span>
</code></pre>
<p>In this example, <code>user</code> is an object containing another object <code>address</code>, which contains the <code>city</code> property.</p>
<p>The expression <code>user.address &amp;&amp; user.address.city</code> is utilizing short-circuiting. It checks if <code>user.address</code> exists and if it does, it further checks if <code>user.address.city</code> exists.</p>
<p>If <code>user.address</code> is truthy (if it exists), JavaScript proceeds to evaluate <code>user.address.city</code>. If <code>user.address</code> is falsy (if it's undefined or null), JavaScript short-circuits the evaluation and doesn't proceed to evaluate <code>user.address.city</code>. </p>
<p>This prevents a potential <code>TypeError</code> if <code>user.address</code> is not defined or null.</p>
<p>Since <code>user.address</code> exists in this case, the expression evaluates to the value of <code>user.address.city</code>, which is <code>'New York'</code>.</p>
<p>This technique ensures safe access to nested properties and helps avoid runtime errors in cases where objects might not be fully populated or structured as expected.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Short-circuiting can greatly enhance your development workflow. </p>
<p>You can practice these concepts in your projects to become proficient in leveraging JavaScript's short-circuiting behavior effectively.</p>
<p>If you have any feedback, feel free to reach out to me on <a target="_blank" href="https://twitter.com/introvertedbot">Twitter</a> and <a target="_blank" href="https://www.linkedin.com/in/sahil-mahapatra/">Linkedin</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ JavaScript Spread and Rest Operators – Explained with Code Examples ]]>
                </title>
                <description>
                    <![CDATA[ In modern JavaScript, the spread and rest operators are indispensable tools for simplifying array manipulation and function parameters. These operators provide elegant solutions for tasks like array expansion and function arguments handling.  Let's d... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/javascript-spread-and-rest-operators/</link>
                <guid isPermaLink="false">66bb88285d242388375d3862</guid>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Operators ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Sahil ]]>
                </dc:creator>
                <pubDate>Thu, 08 Feb 2024 23:27:05 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/02/Copy-of-Neon-Green-Bold-Quote-Motivational-Tweet-Instagram-Post-4-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In modern JavaScript, the spread and rest operators are indispensable tools for simplifying array manipulation and function parameters. These operators provide elegant solutions for tasks like array expansion and function arguments handling. </p>
<p>Let's dive deeper into understanding how they work so you can leverage their power.</p>
<p>You can get all the source code from <a target="_blank" href="https://github.com/dotslashbit/fcc-article-resources/blob/main/javascript-spread-and-rest-operator/index.js">here</a>.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><a class="post-section-overview" href="#heading-the-spread-operator">The Spread Operator</a></li>
<li><a class="post-section-overview" href="#heading-before-the-spread-operator">Before the Spread Operator</a></li>
<li><a class="post-section-overview" href="#heading-after-the-spread-operator">After the Spread Operator</a></li>
<li><a class="post-section-overview" href="#heading-spread-operator-use-cases">Spread Operator Use Cases</a></li>
<li><a class="post-section-overview" href="#heading-the-rest-operator">The Rest Operator</a></li>
<li><a class="post-section-overview" href="#heading-before-the-rest-operator">Before the Rest Operator</a></li>
<li><a class="post-section-overview" href="#heading-after-the-rest-operator">After the Rest Operator</a></li>
<li><a class="post-section-overview" href="#heading-rest-operator-use-cases">Rest Operator Use Cases</a></li>
<li><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></li>
</ul>
<h2 id="heading-the-spread-operator">The Spread Operator</h2>
<p>The spread operator, denoted by three consecutive dots (<code>...</code>), is primarily used for expanding iterables like arrays into individual elements. This operator allows us to efficiently merge, copy, or pass array elements to functions without explicitly iterating through them.</p>
<p>Consider the following array:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Original array:"</span>, arr); <span class="hljs-comment">// [1, 2, 3]</span>
</code></pre>
<h3 id="heading-before-the-spread-operator">Before the Spread Operator</h3>
<p>Traditionally, if we wanted to create a new array with existing elements appended to it, we'd resort to cumbersome approaches like this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> newArr = [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>, arr[<span class="hljs-number">0</span>], arr[<span class="hljs-number">1</span>], arr[<span class="hljs-number">2</span>]];
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"New array (before spread operator):"</span>, newArr); <span class="hljs-comment">// [5, 6, 1, 2, 3]</span>
</code></pre>
<p>This method involves either hard-coding each element or manually looping through the array, resulting in verbose and error-prone code.</p>
<h3 id="heading-after-the-spread-operator">After the Spread Operator</h3>
<p>Enter the spread operator, offering a concise and intuitive alternative:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> newArr = [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>, ...arr];
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"New array (after spread operator):"</span>, newArr); <span class="hljs-comment">// [5, 6, 1, 2, 3]</span>
</code></pre>
<p>In this example, we seamlessly integrate the contents of <code>arr</code> into <code>newArr</code> using the spread operator. No manual indexing or looping is required, making the code more readable and maintainable.</p>
<h3 id="heading-spread-operator-use-cases">Spread Operator Use Cases</h3>
<h4 id="heading-combining-arrays">Combining Arrays</h4>
<p>The spread operator provides an elegant solution for combining multiple arrays into a single array. By spreading each array's elements within a new array, we can concatenate them effortlessly.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr1 = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">const</span> arr2 = [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>];
<span class="hljs-keyword">const</span> combined = [...arr1, ...arr2];
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Combined array:"</span>, combined); <span class="hljs-comment">// [1, 2, 3, 4, 5, 6]</span>
</code></pre>
<p>This approach eliminates the need for manual iteration or concatenation methods, resulting in concise and readable code.</p>
<h4 id="heading-passing-arguments-to-functions">Passing Arguments to Functions</h4>
<p>The spread operator simplifies the process of passing variable-length arguments to functions. Instead of specifying each argument individually, we can use the spread operator to unpack an array of values into function parameters.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sum</span>(<span class="hljs-params">a, b, c</span>) </span>{
    <span class="hljs-keyword">return</span> a + b + c;
}

<span class="hljs-keyword">const</span> nums = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">const</span> result = sum(...nums);
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Result of sum:"</span>, result); <span class="hljs-comment">// 6</span>
</code></pre>
<p>This technique enhances function flexibility and reduces redundancy, especially when dealing with dynamic inputs.</p>
<h4 id="heading-copying-arrays">Copying Arrays</h4>
<p>The spread operator offers a concise method for copying arrays, ensuring that modifications to the copied array do not affect the original. By spreading the original array's elements into a new array, we create a distinct copy.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> original = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
<span class="hljs-keyword">const</span> copy = [...original];
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Copied array:"</span>, copy); <span class="hljs-comment">// [1, 2, 3]</span>
</code></pre>
<p>Unlike traditional methods like <code>slice()</code> or <code>concat()</code>, the spread operator provides a more intuitive and readable approach to array duplication.</p>
<h2 id="heading-the-rest-operator">The Rest Operator</h2>
<p>While the spread operator expands elements, the rest operator condenses them into a single entity within function parameters or array destructuring. It collects remaining elements into a designated variable, facilitating flexible function definitions and array manipulation.</p>
<h3 id="heading-before-the-rest-operator">Before the Rest Operator</h3>
<p>Prior to the rest operator, extracting specific elements from an array while preserving the rest required manual manipulation or looping.</p>
<p>Consider a scenario where we want to extract the first element from an array and collect the rest into a separate array. Before the introduction of the rest operator, achieving this task involved more verbose code:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];

<span class="hljs-keyword">const</span> first = arr[<span class="hljs-number">0</span>]; <span class="hljs-comment">// Extracting the first element</span>
<span class="hljs-keyword">const</span> rest = arr.slice(<span class="hljs-number">1</span>); <span class="hljs-comment">// Collecting the rest of the elements</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"First element:"</span>, first); <span class="hljs-comment">// 1</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Rest of the elements:"</span>, rest); <span class="hljs-comment">// [2, 3, 4, 5]</span>
</code></pre>
<p>In the above example, <code>first</code> captures the initial element (<code>1</code>) by directly accessing it at index <code>0</code>, while <code>rest</code> is obtained by slicing the array from index <code>1</code> onwards. This manual approach is prone to errors and less intuitive compared to using the rest operator.</p>
<h3 id="heading-after-the-rest-operator">After the Rest Operator</h3>
<p>With the introduction of the rest operator, extracting specific elements becomes more intuitive and concise.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> [first, ...rest] = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"First element:"</span>, first); <span class="hljs-comment">// 1</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Rest of the elements:"</span>, rest); <span class="hljs-comment">// [2, 3, 4, 5]</span>
</code></pre>
<p>In this example, <code>first</code> captures the initial element (<code>1</code>), while <code>rest</code> encapsulates the remaining elements (<code>[2, 3, 4, 5]</code>). The rest operator empowers us to handle variable-length inputs with ease.</p>
<h3 id="heading-rest-operator-use-cases">Rest Operator Use Cases</h3>
<h4 id="heading-handling-variable-length-function-arguments">Handling Variable-Length Function Arguments</h4>
<p>The rest operator simplifies the handling of variable-length arguments in functions. It allows functions to accept an indefinite number of arguments without explicitly specifying each one.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">sum</span>(<span class="hljs-params">...numbers</span>) </span>{
    <span class="hljs-keyword">return</span> numbers.reduce(<span class="hljs-function">(<span class="hljs-params">total, num</span>) =&gt;</span> total + num, <span class="hljs-number">0</span>);
}

<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Sum:"</span>, sum(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>)); <span class="hljs-comment">// Sum: 15</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Sum:"</span>, sum(<span class="hljs-number">10</span>, <span class="hljs-number">20</span>)); <span class="hljs-comment">// Sum: 30</span>
</code></pre>
<p>The <code>...numbers</code> syntax collects all passed arguments into an array named <code>numbers</code>, enabling flexible function definitions.</p>
<h4 id="heading-array-destructuring">Array Destructuring</h4>
<p>The rest operator is commonly used in array destructuring to capture remaining elements into a separate array variable.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> [first, second, ...rest] = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"First element:"</span>, first); <span class="hljs-comment">// First element: 1</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Second element:"</span>, second); <span class="hljs-comment">// Second element: 2</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Rest of the elements:"</span>, rest); <span class="hljs-comment">// Rest of the elements: [3, 4, 5]</span>
</code></pre>
<p>This allows for more concise and readable code when working with arrays, especially in scenarios where only the first few elements are of interest.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>That's it! These operators simplify array manipulation and function handling, making your code more efficient and readable. </p>
<p>Whether it's for personal projects or technical assessments, integrating spread and rest operators will enhance your JavaScript skills and problem-solving abilities.</p>
<p>If you have any feedback, then please contact me on <a target="_blank" href="https://twitter.com/introvertedbot">Twitter</a> or <a target="_blank" href="https://www.linkedin.com/in/sahil-mahapatra/">Linkedin</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Advanced JavaScript Operators – Nullish Coalescing, Optional Chaining, and Destructuring Assignment ]]>
                </title>
                <description>
                    <![CDATA[ Hi Everyone! In this article, I'm going to teach you how to use three advanced JavaScript operators: the Nullish Coalescing, Optional Chaining, and Destructuring Assignment operators. These three operators will help you write clearer and less error-p... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/javascript-advanced-operators/</link>
                <guid isPermaLink="false">66bd9169621c718d60a3106b</guid>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Operators ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Nathan Sebhastian ]]>
                </dc:creator>
                <pubDate>Thu, 04 Jan 2024 15:22:39 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2024/01/js-advanced-operators.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Hi Everyone! In this article, I'm going to teach you how to use three advanced JavaScript operators: the Nullish Coalescing, Optional Chaining, and Destructuring Assignment operators.</p>
<p>These three operators will help you write clearer and less error-prone code. </p>
<h2 id="heading-the-nullish-coalescing-operator">The Nullish Coalescing Operator</h2>
<p>When you’re inspecting JavaScript code, you may find an expression using a double question mark (<code>??</code>), as in the code below:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(username ?? <span class="hljs-string">"Guest"</span>);
</code></pre>
<p>The double question mark is a logical operator that returns the expression on the right-hand side of the mark when the expression on the left-hand side is <code>null</code> or <code>undefined</code></p>
<p>This operator is also known as the nullish coalescing operator. It’s a new feature introduced in JavaScript ES2020 that allows you to check for <code>null</code> or <code>undefined</code> values in a more concise way.</p>
<h3 id="heading-nullish-coalescing-operator-syntax">Nullish Coalescing Operator Syntax</h3>
<p>The syntax for the nullish coalescing operator is very simple. It consists of two question marks <code>??</code> placed between two operands.</p>
<p>Here’s an example:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> firstName = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> username = firstName ?? <span class="hljs-string">"Guest"</span>;
<span class="hljs-built_in">console</span>.log(username); <span class="hljs-comment">// "Guest"</span>
</code></pre>
<p>The code above assigns the <code>firstName</code> variable value as the value of the <code>username</code> variable.</p>
<p>When the <code>firstName</code> value is <code>null</code> or <code>undefined</code>, then the value <code>Guest</code> will be assigned to the <code>username</code> variable instead:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/01/nullish-coalescing-output.png" alt="Image" width="600" height="400" loading="lazy">
<em>Result of using the nullish coalescing operator</em></p>
<p>You can also write it this way:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> username = <span class="hljs-literal">undefined</span> ?? <span class="hljs-string">"Guest"</span>;
<span class="hljs-built_in">console</span>.log(username); <span class="hljs-comment">// "Guest"</span>
</code></pre>
<p>As you can see, you don’t need an <code>if-else</code> statement to check for <code>null</code> or <code>undefined</code> values.</p>
<h3 id="heading-why-javascript-needs-this-operator">Why JavaScript Needs This Operator</h3>
<p>The nullish coalescing operator was created as an improved alternative to the OR operator <code>||</code>.</p>
<p>The OR operator was originally created to provide a default or fallback value when the left-hand expression is falsy, or evaluates to <code>false</code>.</p>
<p>But after some real-world uses, it’s clear that there are times when developers want to return values that are considered falsy, such as <code>0</code> and an empty string (<code>""</code>)</p>
<p>The use of the OR operator will prevent you from returning any falsy values at all. Consider the following example:</p>
<pre><code class="lang-js"><span class="hljs-comment">// empty string evaluates to false in JavaScript:</span>
<span class="hljs-keyword">let</span> firstName = <span class="hljs-string">""</span>;
<span class="hljs-keyword">let</span> username = firstName ?? <span class="hljs-string">"Guest"</span>;
<span class="hljs-built_in">console</span>.log(username); <span class="hljs-comment">// ""</span>

<span class="hljs-comment">// When you use OR operator:</span>
username = firstName || <span class="hljs-string">"Guest"</span>;
<span class="hljs-built_in">console</span>.log(username); <span class="hljs-comment">// "Guest"</span>
</code></pre>
<p>By using the nullish coalescing operator, you will only replace <strong>exactly</strong> <code>null</code> and <code>undefined</code> values with the right-hand value.</p>
<p>The nullish coalescing operator can be used with any type of value, including numbers, strings, and objects.</p>
<h3 id="heading-nullish-coalescing-operator-use-cases">Nullish Coalescing Operator Use Cases</h3>
<p>The nullish coalescing operator is useful in a variety of situations where you need to check for <code>null</code> or <code>undefined</code> values and provide a default value.</p>
<p>Here are several examples of common use cases:</p>
<h4 id="heading-handling-missing-function-arguments">Handling Missing Function Arguments</h4>
<p>When a function is called, it’s possible that some of the arguments may be omitted.</p>
<p>The Nullish Coalescing Operator can be used to provide default values for a missing argument as follows:</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">greet</span>(<span class="hljs-params">name</span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`Hello, <span class="hljs-subst">${name ?? <span class="hljs-string">"Guest"</span>}</span>!`</span>);
}

greet(); <span class="hljs-comment">// 'Hello, Guest!'</span>
greet(<span class="hljs-string">"John"</span>); <span class="hljs-comment">// 'Hello, John!'</span>
</code></pre>
<h4 id="heading-accessing-object-properties">Accessing Object Properties</h4>
<p>When working with objects, it’s possible that a property may not exist or is <code>undefined</code>.</p>
<p>The Nullish Coalescing Operator can be used to safely access object properties and provide a default value when the property is missing:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> user = { <span class="hljs-attr">name</span>: <span class="hljs-string">"John Doe"</span> };
<span class="hljs-keyword">let</span> email = user.email ?? <span class="hljs-string">"N/A"</span>;
<span class="hljs-built_in">console</span>.log(email); <span class="hljs-comment">// 'N/A'</span>
</code></pre>
<h4 id="heading-choosing-between-a-variable-and-a-constant">Choosing Between a Variable and a Constant</h4>
<p>You may want to select a value from a variable or a constant if the variable is <code>null</code> or <code>undefined</code>:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> value = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">const</span> DEFAULT_VALUE = <span class="hljs-string">'Default'</span>;

<span class="hljs-keyword">let</span> result = value ?? DEFAULT_VALUE;

<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// 'Default'</span>
</code></pre>
<p>As you can see, the Nullish Coalescing Operator is a great feature that can make your code more concise and reliable.</p>
<h3 id="heading-using-with-the-and-ampamp-operators">Using <code>??</code> with the <code>||</code> and <code>&amp;&amp;</code> Operators</h3>
<p>For safety reasons, the double question mark can’t be used together with JavaScript OR (<code>||</code>) and AND (<code>&amp;&amp;</code>) operators without parentheses <code>()</code> separating the operators.</p>
<p>For example, the following code tries to see if either <code>firstName</code> or <code>lastName</code> variable can be used as the value of <code>username</code> before using <code>"Guest"</code> as its value:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> firstName = <span class="hljs-string">"John"</span>;
<span class="hljs-keyword">let</span> lastName = <span class="hljs-string">"Stone"</span>;
<span class="hljs-keyword">let</span> username = firstName || lastName ?? <span class="hljs-string">"Guest"</span>;
<span class="hljs-comment">// Error: Unexpected token '??'</span>

<span class="hljs-built_in">console</span>.log(username);
</code></pre>
<p>This is because JavaScript won’t be able to determine which operator it needs to evaluate first. You need to use parentheses to clearly indicate the priority of the evaluations.</p>
<p>The following code will first evaluate the expressions inside the parentheses:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> firstName = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> lastName = <span class="hljs-literal">undefined</span>;
<span class="hljs-keyword">let</span> username = (firstName || lastName) ?? <span class="hljs-string">"Guest"</span>;

<span class="hljs-built_in">console</span>.log(username); <span class="hljs-comment">// "Guest"</span>
</code></pre>
<p>And that’s how you combine the nullish coalescing operator with either AND or OR operator.</p>
<h2 id="heading-the-optional-chaining-operator">The Optional Chaining Operator</h2>
<p>Like the nullish coalescing operator, the optional chaining operator is a modern addition to JavaScript that offers a better way to do things.</p>
<p>The optional chaining operator <code>?.</code> gives you a safe way to access properties and methods of an object, avoiding an error in the process.</p>
<p>One of the most common problems in JavaScript is that you can get an error when you access a property of an <code>undefined</code> value.</p>
<p>For example, suppose you have a <code>car</code> object as follows:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> car = {};

<span class="hljs-built_in">console</span>.log(car.manufacturer); <span class="hljs-comment">// undefined</span>
<span class="hljs-built_in">console</span>.log(car.manufacturer.address); <span class="hljs-comment">// ❌ TypeError!</span>
</code></pre>
<p>In the example above, accessing the <code>manufacturer</code> property returns <code>undefined</code>, but when you try to access the <code>address</code> property of the <code>manufacturer</code> property, JavaScript returns an error.</p>
<p>Even though this is how JavaScript works, a better way to handle the non-existent property would be to just return an <code>undefined</code> back, just like when we try to access the <code>manufacturer</code> property.</p>
<p>This is why the optional chaining operator was created. The operator returns either the value of the property, or <code>undefined</code> when the property is <code>null</code> or <code>undefined</code>.</p>
<p>To use the operator, just add a question mark in front of the dot <code>.</code> notation:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> car = {};

<span class="hljs-built_in">console</span>.log(car.manufacturer?.address); <span class="hljs-comment">// undefined</span>
</code></pre>
<p>The optional chaining operator can be added anytime you use the dot notation to access a property or method.</p>
<p>This operator allows you to avoid the TypeError that occurs when accessing a property or calling a method from a non-existent property:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> car = {};

<span class="hljs-built_in">console</span>.log(car.manufacturer?.address); <span class="hljs-comment">// undefined</span>
<span class="hljs-built_in">console</span>.log(car.manufacturer?.drive()); <span class="hljs-comment">// undefined</span>
</code></pre>
<p>Note that the optional chaining operator only checks the value before it. If the <code>car</code> variable can be <code>null</code>, then you need to add the operator after when accessing the <code>car</code> object as well.</p>
<p>See the following example:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> car = <span class="hljs-literal">null</span>;

<span class="hljs-built_in">console</span>.log(car?.manufacturer?.address); <span class="hljs-comment">// undefined</span>
<span class="hljs-built_in">console</span>.log(car.manufacturer?.address); <span class="hljs-comment">// TypeError: Cannot read properties of null</span>
</code></pre>
<p>And that’s how the optional chaining operator works. It’s really useful when you’re working with objects in your project.</p>
<p>Next, let’s learn about the destructuring assignment.</p>
<h2 id="heading-destructuring-assignment-operator">Destructuring Assignment Operator</h2>
<p>The destructuring assignment is a special operator that allows you to "unpack" or "extract" the values of JavaScript arrays and objects. It has become one of the most useful features of JavaScript language for two reasons:</p>
<ul>
<li>It helps you to avoid code repetition.</li>
<li>It keeps your code clean and easy to understand.</li>
</ul>
<p>Let’s see how you can destructure an array and an object next.</p>
<h3 id="heading-destructuring-arrays">Destructuring Arrays</h3>
<p>Here’s how you normally assign an array values to variables:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> sampleArray = [<span class="hljs-string">'Jane'</span>, <span class="hljs-string">'John'</span>];

<span class="hljs-keyword">const</span> firstIndex = sampleArray[<span class="hljs-number">0</span>];
<span class="hljs-keyword">const</span> secondIndex = sampleArray[<span class="hljs-number">1</span>];
</code></pre>
<p>The code above works, but you need two lines of code to get two elements from an array. Using the destructuring assignment, you can assign array elements into variables in one short line:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> sampleArray = [<span class="hljs-string">'Jane'</span>, <span class="hljs-string">'John'</span>];

<span class="hljs-keyword">const</span> [firstIndex, secondIndex] = sampleArray;
</code></pre>
<p>The above code will return the same value for <code>firstIndex</code> and <code>secondIndex</code> variable. No matter how many elements you have, the destructuring will start from the zero index.</p>
<p>To create a destructuring assignment, you need to add square brackets <code>[]</code> after the <code>let</code>/ <code>const</code> keyword. When you add square brackets after the assignment (<code>=</code>) operator, it’s an array. If you add them before the assignment operator, it’s a destructuring assignment.</p>
<p>You can also use the rest operator <code>…​</code> to copy the rest of the values after your assignment. Take a look at the following example:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> sampleArray = [<span class="hljs-string">'Jane'</span>, <span class="hljs-string">'John'</span>, <span class="hljs-string">'Jack'</span>, <span class="hljs-string">'Aston'</span>];

<span class="hljs-keyword">const</span> [one, two, ...rest] = sampleArray;
</code></pre>
<p>The <code>rest</code> variable will contain an array with values of <code>['Jack','Aston']</code>.</p>
<p>You can also put default values for these variables when the extracted value is undefined:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> [a = <span class="hljs-string">'Martin'</span>, b = <span class="hljs-number">10</span>] = [<span class="hljs-literal">true</span>];

<span class="hljs-comment">// a will return true</span>
<span class="hljs-comment">// b will return 10</span>
</code></pre>
<p>You can also immediately assign the return of a function into assignments. This is frequently used in libraries like React:</p>
<pre><code class="lang-jsx"><span class="hljs-keyword">const</span> [a, b] = myFunction();

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">myFunction</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> [<span class="hljs-string">'John'</span>, <span class="hljs-string">'Jack'</span>];
}
</code></pre>
<p>The variable <code>a</code> will return "John" and <code>b</code> will return "Jack".</p>
<p>Finally, you can also ignore some variables by skipping the assignment for that index:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> [a, , b] = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];

<span class="hljs-comment">// a will return 1</span>
<span class="hljs-comment">// b will return 3</span>
</code></pre>
<p>Destructuring assignment makes unpacking array values easier and shorter, with less repetition.</p>
<h3 id="heading-object-destructuring">Object Destructuring</h3>
<p>Just like arrays, you can destructure objects the same way, but instead of using the square brackets (<code>[]</code>) you need to use the curly brackets (<code>{}</code>):</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> user = {
  <span class="hljs-attr">firstName</span>: <span class="hljs-string">'Jack'</span>,
  <span class="hljs-attr">lastName</span>: <span class="hljs-string">'Smith'</span>,
};

<span class="hljs-keyword">const</span> { firstName, lastName } = user;
</code></pre>
<p>You can use the colon delimiter (<code>:</code>) to assign the property into a different name. The example below assign the value of <code>firstName</code> into <code>name</code>:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> user = {
  <span class="hljs-attr">firstName</span>: <span class="hljs-string">'Jack'</span>,
  <span class="hljs-attr">lastName</span>: <span class="hljs-string">'Smith'</span>,
};

<span class="hljs-keyword">const</span> { <span class="hljs-attr">firstName</span>: name, lastName } = user;
</code></pre>
<p>Note that you still only create two variables: <code>name</code> and <code>lastName</code>. The <code>firstName</code> is assigned to <code>name</code>, so it won’t create a separate variable.</p>
<p>Just like arrays, you can destructure an object returned by a function immediately:</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">myFunction</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> { <span class="hljs-attr">firstName</span>: <span class="hljs-string">'Jack'</span>, <span class="hljs-attr">lastName</span>: <span class="hljs-string">'Austin'</span> };
}

<span class="hljs-keyword">const</span> { firstName, lastName } = myFunction();
</code></pre>
<p>Also, you can destructure an object from the function parameters, exactly when you define the function:</p>
<pre><code class="lang-js"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">myFunction</span>(<span class="hljs-params">{ firstName, lastName }</span>) </span>{
  <span class="hljs-keyword">return</span> firstName + <span class="hljs-string">' '</span> + lastName;
}

<span class="hljs-keyword">const</span> user = {
  <span class="hljs-attr">firstName</span>: <span class="hljs-string">'Jack'</span>,
  <span class="hljs-attr">lastName</span>: <span class="hljs-string">'Austin'</span>,
};

<span class="hljs-keyword">const</span> name = myFunction(user);
</code></pre>
<p>The destructuring assignment is a useful addition to JavaScript that makes it easier to unpack values from objects and arrays. You’re going to use it frequently when you code using a library like React.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>JavaScript is constantly improving every year, and the three operators explained in this article are a great addition that can help you produce more concise and readable code.</p>
<p>If you enjoyed this article and want to take your JavaScript skills to the next level, I recommend you check out my new book <em>Beginning Modern JavaScript</em> <a target="_blank" href="https://www.amazon.com/dp/B0CQXHMF8G">here</a>.</p>
<p><a target="_blank" href="https://www.amazon.com/dp/B0CQXHMF8G"><img src="https://www.freecodecamp.org/news/content/images/2024/01/beginning-js-cover.png" alt="beginning-js-cover" width="600" height="400" loading="lazy"></a></p>
<p>The book is designed to be easy to understand and accessible to anyone looking to learn JavaScript. It provides a step-by-step gentle guide that will help you understand how to use JavaScript to create a dynamic application.</p>
<p>Here's my promise: <em>You will actually feel like you understand what you're doing with JavaScript.</em></p>
<p>Until next time!  </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Learn JavaScript Operators – Logical, Comparison, Ternary, and More JS Operators With Examples ]]>
                </title>
                <description>
                    <![CDATA[ JavaScript has many operators that you can use to perform operations on values and variables (also called operands) Based on the types of operations these JS operators perform, we can divide them up into seven groups: Arithmetic Operators Assignment... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/javascript-operators/</link>
                <guid isPermaLink="false">66bd918927629f4c5e1893b8</guid>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Operators ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Nathan Sebhastian ]]>
                </dc:creator>
                <pubDate>Mon, 14 Aug 2023 15:44:58 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/08/JS-EVERY-OPERATOR.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>JavaScript has many operators that you can use to perform operations on values and variables (also called operands)</p>
<p>Based on the types of operations these JS operators perform, we can divide them up into seven groups:</p>
<ol>
<li><a class="post-section-overview" href="#heading-arithmetic-operators">Arithmetic Operators</a></li>
<li><a class="post-section-overview" href="#heading-assignment-operators">Assignment Operators</a></li>
<li><a class="post-section-overview" href="#heading-comparison-operators">Comparison Operators</a></li>
<li><a class="post-section-overview" href="#heading-logical-operators">Logical Operators</a></li>
<li><a class="post-section-overview" href="#heading-ternary-operator">Ternary Operators</a></li>
<li><a class="post-section-overview" href="#heading-the-typeof-operator">The <code>typeof</code> Operator</a></li>
<li><a class="post-section-overview" href="#heading-bitwise-operators">Bitwise Operators</a></li>
</ol>
<p>In this handbook, you're going to learn how these operators work with examples. Let's start with arithmetic operators.</p>
<h2 id="heading-arithmetic-operators">Arithmetic Operators</h2>
<p>The arithmetic operators are used to perform mathematical operations like addition and subtraction.</p>
<p>These operators are frequently used with number data types, so they are similar to a calculator. The following example shows how you can use the <code>+</code> operator to add two variables together:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">3</span>;
<span class="hljs-keyword">let</span> y = <span class="hljs-number">8</span>;

<span class="hljs-built_in">console</span>.log(x + y); <span class="hljs-comment">// 11</span>
</code></pre>
<p>Here, the two variables <code>x</code> and <code>y</code> are added together using the plus <code>+</code> operator. We also used the <code>console.log()</code> method to print the result of the operation to the screen.</p>
<p>You can use operators directly on values without assigning them to any variable too:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">2</span> + <span class="hljs-number">1</span>); <span class="hljs-comment">// 3</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">4</span> + <span class="hljs-number">1</span>); <span class="hljs-comment">// 5</span>
</code></pre>
<p>In JavaScript, we have 8 arithmetic operators in total. They are:</p>
<ol>
<li>Addition <code>+</code></li>
<li>Subtraction <code>-</code></li>
<li>Multiplication <code>*</code></li>
<li>Division <code>/</code></li>
<li>Remainder <code>%</code></li>
<li>Exponentiation <code>**</code></li>
<li>Increment <code>++</code></li>
<li>Decrement <code>--</code></li>
</ol>
<p>Let's see how these operators work one by one.</p>
<h3 id="heading-1-addition-operator">1. Addition operator</h3>
<p>The addition operator <code>+</code> is used to add two or more numbers together. You've seen how this operator works previously, but here's another example:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">7</span> + <span class="hljs-number">2</span>); <span class="hljs-comment">// 9</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">2.3</span> + <span class="hljs-number">1.5</span>); <span class="hljs-comment">// 3.8</span>
</code></pre>
<p>You can use the addition operator on both integer and floating numbers.</p>
<h3 id="heading-2-subtraction-operator">2. Subtraction operator</h3>
<p>The subtraction operator is marked by the minus sign <code>−</code> and you can use it to subtract the right operand from the left operand.</p>
<p>For example, here's how to subtract 3 from 5:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;
<span class="hljs-keyword">let</span> y = <span class="hljs-number">3</span>;

<span class="hljs-built_in">console</span>.log(x - y); <span class="hljs-comment">// 2</span>
</code></pre>
<h3 id="heading-3-multiplication-operator">3. Multiplication operator</h3>
<p>The multiplication operator is marked by the asterisk <code>*</code> symbol, and you use it to multiply the value on the left by the value on the right of the operator.</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> * <span class="hljs-number">2</span>); <span class="hljs-comment">// 10</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">3</span> * <span class="hljs-number">3</span>); <span class="hljs-comment">// 9</span>
</code></pre>
<h3 id="heading-4-division-operator">4. Division operator</h3>
<p>The division operator <code>/</code> is used to divide the left operand by the right operand. Here are some examples of using the operator:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">10</span> / <span class="hljs-number">2</span>); <span class="hljs-comment">// 5</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">9</span> / <span class="hljs-number">3</span>); <span class="hljs-comment">// 3</span>
</code></pre>
<h3 id="heading-5-remainder-operator">5. Remainder operator</h3>
<p>The remainder operator <code>%</code> is also known as the modulo or modulus operator. This operator is used to calculate the remainder after a division has been performed.</p>
<p>A practical example should make this operator easier to understand, so let's see one:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">10</span> % <span class="hljs-number">3</span>);
</code></pre>
<p>The number 10 can't be divided by 3 perfectly. The result of the division is 3 with a remainder of 1. The remainder operator simply returns that remainder number.</p>
<p>If the left operand can be divided with no remainder, then the operator returns 0.</p>
<p>This operator is commonly used when you want to check if a number is even or odd. If a number is even, dividing it by 2 will result in a remainder of 0, and if it's odd, the remainder will be 1.</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">1</span> % <span class="hljs-number">2</span>); <span class="hljs-comment">// 1</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">2</span> % <span class="hljs-number">2</span>); <span class="hljs-comment">// 0</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">3</span> % <span class="hljs-number">2</span>); <span class="hljs-comment">// 1</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">4</span> % <span class="hljs-number">2</span>); <span class="hljs-comment">// 0</span>
</code></pre>
<h3 id="heading-6-exponentiation-operator">6. Exponentiation operator</h3>
<p>The exponentiation operator is marked by two asterisks <code>**</code>. It's one of the newer JavaScript operators and you can use it to calculate the power of a number (based on its exponent).</p>
<p>For example, here's how to calculate 10 to the power of 3:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">10</span> ** <span class="hljs-number">3</span>); <span class="hljs-comment">// 1000</span>
</code></pre>
<p>Here, the number 10 is multiplied by itself 3 times (10 <em> 10 </em> 10)</p>
<p>The exponentiation operator gives you an easy way to find the power of a specific number.</p>
<h3 id="heading-7-increment-operator">7. Increment operator</h3>
<p>The increment <code>++</code> operator is used to increase the value of a number by one. For example:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;

x++;

<span class="hljs-built_in">console</span>.log(x); <span class="hljs-comment">// 6</span>
</code></pre>
<p>This operator gives you a faster way to increase a variable value by one. Without the operator, here's how you increment a variable:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;

x = x + <span class="hljs-number">1</span>;

<span class="hljs-built_in">console</span>.log(x); <span class="hljs-comment">// 6</span>
</code></pre>
<p>Using the increment operator allows you to shorten the second line. You can place this operator before or next to the variable you want to increment:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;

<span class="hljs-comment">// Place the operator next to the variable (postfix)</span>
x++;

<span class="hljs-comment">// Place the operator before the variable (prefix)</span>
++x;
</code></pre>
<p>Both placements shown above are valid. The difference between prefix (before) and postfix (after) placements is that the prefix position will execute the operator after that line of code has been executed.</p>
<p>Consider the following example:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;
<span class="hljs-keyword">let</span> y = <span class="hljs-number">5</span>;

<span class="hljs-built_in">console</span>.log(x++); <span class="hljs-comment">// 5</span>
<span class="hljs-built_in">console</span>.log(x); <span class="hljs-comment">// 6</span>

<span class="hljs-built_in">console</span>.log(++y); <span class="hljs-comment">// 6</span>
<span class="hljs-built_in">console</span>.log(y); <span class="hljs-comment">// 6</span>
</code></pre>
<p>Here, you can see that placing the increment operator next to the variable will print the variable as if it has not been incremented.</p>
<p>When you place the operator before the variable, then the number will be incremented before calling the <code>console.log()</code> method.</p>
<h3 id="heading-8-decrement-operator">8. Decrement operator</h3>
<p>The decrement <code>--</code> operator is used to decrease the value of a number by one. It's the opposite of the increment operator:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;

x--;

<span class="hljs-built_in">console</span>.log(x); <span class="hljs-comment">// 4</span>
</code></pre>
<p>Please note that you can only use increment and decrement operators on a variable. An error occurs when you try to use these operators directly on a number value:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span>--);
</code></pre>
<p><strong>Output:</strong></p>
<pre><code class="lang-txt">Uncaught SyntaxError: Invalid left-hand side expression in postfix operation
</code></pre>
<p>You can't use increment or decrement operator on a number directly.</p>
<h3 id="heading-arithmetic-operators-summary">Arithmetic operators summary</h3>
<p>Now you've learned the 8 types of arithmetic operators. Excellent! Keep in mind that you can mix these operators to perform complex mathematical equations.</p>
<p>For example, you can perform an addition and multiplication on a set of numbers:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> + <span class="hljs-number">2</span> * <span class="hljs-number">3</span>); <span class="hljs-comment">// 11</span>
</code></pre>
<p>The order of operations in JavaScript is the same as in mathematics. Multiplication, division, and exponentiation take a higher priority than addition or subtraction (remember that acronym PEMDAS? Parentheses, exponents, multiplication and division, addition and subtraction – there's your order of operations).</p>
<p>You can use parentheses <code>()</code> to change the order of the operations. Wrap the operation you want to execute first as follows:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log((<span class="hljs-number">5</span> + <span class="hljs-number">2</span>) * <span class="hljs-number">3</span>); <span class="hljs-comment">// 21</span>
</code></pre>
<p>When using increment or decrement operators together with other operators, you need to place the operators in a prefix position as follows:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">2</span> + ++x); <span class="hljs-comment">// 2 + 6 = 8</span>
</code></pre>
<p>This is because a postfix increment or decrement operator will not be executed together with other operations in the same line, as I have explained previously.</p>
<p>Let's try some exercises. Can you guess the result of these operations?</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> * <span class="hljs-number">3</span> - <span class="hljs-number">2</span>);
<span class="hljs-built_in">console</span>.log((<span class="hljs-number">3</span> * <span class="hljs-number">6</span>) % <span class="hljs-number">2</span>);
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> + <span class="hljs-number">7</span> - <span class="hljs-number">1</span>);
<span class="hljs-built_in">console</span>.log((<span class="hljs-number">4</span> + <span class="hljs-number">9</span>) * <span class="hljs-number">4</span>);

<span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;
<span class="hljs-built_in">console</span>.log(++x);
<span class="hljs-built_in">console</span>.log(x++ / <span class="hljs-number">3</span>);
</code></pre>
<p>And that's all for arithmetic operators. You've done a wonderful job learning about these operators.</p>
<p>Let's take a short five-minute break before proceeding to the next type of operators.</p>
<h2 id="heading-assignment-operators">Assignment Operators</h2>
<p>The second group of operators we're going to explore is the assignment operators.</p>
<p>Assignment operators are used to assign a specific value to a variable. The basic assignment operator is marked by the equal <code>=</code> symbol, and you've already seen this operator in action before:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;
</code></pre>
<p>After the basic assignment operator, there are 5 more assignment operators that combine mathematical operations with the assignment. These operators are useful to make your code clean and short.</p>
<p>For example, suppose you want to increment the <code>x</code> variable by 2. Here's how you do it with the basic assignment operator:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;

x = x + <span class="hljs-number">2</span>;
</code></pre>
<p>There's nothing wrong with the code above, but you can use the addition assignment <code>+=</code> to rewrite the second line as follows:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;

x += <span class="hljs-number">2</span>;
</code></pre>
<p>There are 7 kinds of assignment operators that you can use in JavaScript:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Name</td><td>Operation example</td><td>Meaning</td></tr>
</thead>
<tbody>
<tr>
<td>Assignment</td><td><code>x = y</code></td><td><code>x = y</code></td></tr>
<tr>
<td>Addition assignment</td><td><code>x += y</code></td><td><code>x = x + y</code></td></tr>
<tr>
<td>Subtraction assignment</td><td><code>x -= y</code></td><td><code>x = x - y</code></td></tr>
<tr>
<td>Multiplication assignment</td><td><code>x *= y</code></td><td><code>x = x * y</code></td></tr>
<tr>
<td>Division assignment</td><td><code>x /= y</code></td><td><code>x = x / y</code></td></tr>
<tr>
<td>Remainder assignment</td><td><code>x %= y</code></td><td><code>x = x % y</code></td></tr>
<tr>
<td>Exponentiation assignment</td><td><code>x **= y</code></td><td><code>x = x ** y</code></td></tr>
</tbody>
</table>
</div><p>The arithmetic operators you've learned in the previous section can be combined with the assignment operator except the increment and decrement operators.</p>
<p>Let's have a quick exercise. Can you guess the results of these assignments?</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">3</span>;

x += <span class="hljs-number">2</span> * <span class="hljs-number">3</span>;
<span class="hljs-built_in">console</span>.log(x);

x -= <span class="hljs-number">3</span>;
<span class="hljs-built_in">console</span>.log(x);

x %= <span class="hljs-number">2</span>;
<span class="hljs-built_in">console</span>.log(x);
</code></pre>
<p>Now you've learned about assignment operators. Let's continue and learn about comparison operators.</p>
<h2 id="heading-comparison-operators">Comparison Operators</h2>
<p>As the name implies, comparison operators are used to compare one value or variable with something else. The operators in this category always return a boolean value: either <code>true</code> or <code>false</code>.</p>
<p>For example, suppose you want to compare if a variable's value is greater than 1. Here's how you do it:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;

<span class="hljs-built_in">console</span>.log(x &gt; <span class="hljs-number">1</span>); <span class="hljs-comment">// true</span>
<span class="hljs-built_in">console</span>.log(x &gt; <span class="hljs-number">7</span>); <span class="hljs-comment">// false</span>
</code></pre>
<p>The greater than <code>&gt;</code> operator checks if the value on the left operand is greater than the value on the right operand.</p>
<p>There are 8 kinds of comparison operators available in JavaScript:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Name</td><td>Operation example</td><td>Meaning</td></tr>
</thead>
<tbody>
<tr>
<td>Equal</td><td><code>x == y</code></td><td>Returns <code>true</code> if the operands are equal</td></tr>
<tr>
<td>Not equal</td><td><code>x != y</code></td><td>Returns <code>true</code> if the operands are not equal</td></tr>
<tr>
<td>Strict equal</td><td><code>x === y</code></td><td>Returns <code>true</code> if the operands are equal and have the same type</td></tr>
<tr>
<td>Strict not equal</td><td><code>x !== y</code></td><td>Returns <code>true</code> if the operands are not equal, or have different types</td></tr>
<tr>
<td>Greater than</td><td><code>x &gt; y</code></td><td>Returns <code>true</code> if the left operand is greater than the right operand</td></tr>
<tr>
<td>Greater than or equal</td><td><code>x &gt;= y</code></td><td>Returns <code>true</code> if the left operand is greater than or equal to the right operand</td></tr>
<tr>
<td>Less than</td><td><code>x &lt; y</code></td><td>Returns <code>true</code> if the left operand is less than the right operand</td></tr>
<tr>
<td>Less than or equal</td><td><code>x &lt;= y</code></td><td>Returns <code>true</code> if the left operand is less than or equal to the right operand</td></tr>
</tbody>
</table>
</div><p>Here are some examples of using comparison operators:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">9</span> == <span class="hljs-number">9</span>); <span class="hljs-comment">// true</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-number">9</span> != <span class="hljs-number">20</span>); <span class="hljs-comment">// true</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-number">2</span> &gt; <span class="hljs-number">10</span>); <span class="hljs-comment">// false</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-number">2</span> &lt; <span class="hljs-number">10</span>); <span class="hljs-comment">// true</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> &gt;= <span class="hljs-number">10</span>); <span class="hljs-comment">// false</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-number">10</span> &lt;= <span class="hljs-number">10</span>); <span class="hljs-comment">// true</span>
</code></pre>
<p>The comparison operators are further divided in two types: relational and equality operators.</p>
<p>The relational operators compare the value of one operand relative to the second operand (greater than, less than)</p>
<p>The equality operators check if the value on the left is equal to the value on the right. They can also be used to compare strings like this:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-string">"ABC"</span> == <span class="hljs-string">"ABC"</span>); <span class="hljs-comment">// true</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"ABC"</span> == <span class="hljs-string">"abc"</span>); <span class="hljs-comment">// false</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Z"</span> != <span class="hljs-string">"A"</span>); <span class="hljs-comment">// true</span>
</code></pre>
<p>String comparisons are case-sensitive, as shown in the example above.</p>
<p>JavaScript also has two versions of the equality operators: loose and strict.</p>
<p>In strict mode, JavaScript will compare the values without performing a type coercion. To enable strict mode, you need to add one more equal <code>=</code> symbol to the operation as follows:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-string">"9"</span> == <span class="hljs-number">9</span>); <span class="hljs-comment">// true</span>
<span class="hljs-comment">// strict equal</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"9"</span> === <span class="hljs-number">9</span>); <span class="hljs-comment">// false</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"1"</span> != <span class="hljs-number">1</span>); <span class="hljs-comment">// false</span>
<span class="hljs-comment">// strict not equal</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"1"</span> !== <span class="hljs-number">1</span>); <span class="hljs-comment">// true</span>
</code></pre>
<p>Since type coercion might result in unwanted behavior, you should use the strict equality operators anytime you do an equality comparison.</p>
<h2 id="heading-logical-operators">Logical Operators</h2>
<p>Logical operators are used to check whether one or more expressions result in either <code>true</code> or <code>false</code>.</p>
<p>There are three logical operators available in JavaScript:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Name</td><td>Operation example</td><td>Meaning</td></tr>
</thead>
<tbody>
<tr>
<td>Logical AND</td><td><code>x &amp;&amp; y</code></td><td>Returns <code>true</code> if all operands are <code>true</code>, else returns <code>false</code></td></tr>
<tr>
<td>Logical OR</td><td>`x</td><td></td><td>y`</td><td>Returns <code>true</code> if one of the operands is <code>true</code>, else returns <code>false</code></td></tr>
<tr>
<td>Logical NOT</td><td><code>!x</code></td><td>Reverse the result: returns <code>true</code> if <code>false</code> and vice versa</td></tr>
</tbody>
</table>
</div><p>These operators can only return Boolean values. For example, you can determine whether '7 is greater than 2' and '5 is greater than 4':</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">7</span> &gt; <span class="hljs-number">2</span> &amp;&amp; <span class="hljs-number">5</span> &gt; <span class="hljs-number">4</span>); <span class="hljs-comment">// true</span>
</code></pre>
<p>These logical operators follow the laws of mathematical logic:</p>
<ol>
<li><code>&amp;&amp;</code> AND operator – if any expression returns <code>false</code>, the result is <code>false</code></li>
<li><code>||</code> OR operator – if any expression returns <code>true</code>, the result is <code>true</code></li>
<li><code>!</code> NOT operator – negates the expression, returning the opposite.</li>
</ol>
<p>Let's do a little exercise. Try to run these statements on your computer. Can you guess the results?</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-literal">true</span> &amp;&amp; <span class="hljs-literal">false</span>);

<span class="hljs-built_in">console</span>.log(<span class="hljs-literal">false</span> || <span class="hljs-literal">false</span>);

<span class="hljs-built_in">console</span>.log(!<span class="hljs-literal">true</span>);
</code></pre>
<p>These logical operators will come in handy when you need to assert that a specific requirement is fulfilled in your code.</p>
<p>Let's say a <code>happyLife</code> requires a job with <code>highIncome</code> and <code>supportiveTeam</code>:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> highIncome = <span class="hljs-literal">true</span>;
<span class="hljs-keyword">let</span> supportiveTeam = <span class="hljs-literal">true</span>;
<span class="hljs-keyword">let</span> happyLife = highIncome &amp;&amp; supportiveTeam;

<span class="hljs-built_in">console</span>.log(happyLife); <span class="hljs-comment">// true</span>
</code></pre>
<p>Based on the requirements, you can use the logical AND operator to check whether you have both requirements. When one of the requirements is <code>false</code>, then <code>happyLife</code> equals <code>false</code> as well.</p>
<h2 id="heading-ternary-operator">Ternary Operator</h2>
<p>The ternary operator (also called the conditional operator) is the only JavaScipt operator that requires 3 operands to run.</p>
<p>Let's imagine you need to implement some specific logic in your code. Suppose you're opening a shop to sell fruit. You give a $3 discount when the total purchase is $20 or more. Otherwise, you give a $1 discount.</p>
<p>You can implement the logic using an <code>if..else</code> statement as follows:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> totalPurchase = <span class="hljs-number">15</span>;

<span class="hljs-keyword">let</span> discount;

<span class="hljs-keyword">if</span> (totalPurchase &gt;= <span class="hljs-number">20</span>) {
  discount = <span class="hljs-number">3</span>;
} <span class="hljs-keyword">else</span> {
  discount = <span class="hljs-number">1</span>;
}
</code></pre>
<p>The code above works fine, but you can use the ternary operator to make the code shorter and more concise as follows:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> totalPurchase = <span class="hljs-number">15</span>;

<span class="hljs-keyword">let</span> discount = totalPurchase &gt;= <span class="hljs-number">20</span> ? <span class="hljs-number">3</span> : <span class="hljs-number">1</span>;
</code></pre>
<p>The syntax for the ternary operator is <code>condition ? expression1 : expression2</code>.</p>
<p>You need to write the <code>condition</code> to evaluate followed by a question <code>?</code> mark. </p>
<p>Next to the question mark, you write the expression to execute when the condition evaluates to <code>true</code>, followed by a colon <code>:</code> symbol. You can call this <code>expression1</code>.</p>
<p>Next to the colon symbol, you write the expression to execute when the condition evaluates to <code>false</code>. This is <code>expression2</code>.</p>
<p>As the example above shows, the ternary operator can be used as an alternative to the <code>if..else</code> statement.</p>
<h2 id="heading-the-typeof-operator">The <code>typeof</code> Operator</h2>
<p>The <code>typeof</code> operator is the only operator that's not represented by symbols. This operator is used to check the data type of the value you placed on the right side of the operator.</p>
<p>Here are some examples of using the operator:</p>
<pre><code class="lang-js"><span class="hljs-keyword">let</span> x = <span class="hljs-number">5</span>;
<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> x) <span class="hljs-comment">//  'number'</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> <span class="hljs-string">"Nathan"</span>) <span class="hljs-comment">// 'string'</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> <span class="hljs-literal">true</span>) <span class="hljs-comment">// 'boolean'</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> <span class="hljs-literal">null</span>) <span class="hljs-comment">// 'object'</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]) <span class="hljs-comment">// 'object'</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> {}) <span class="hljs-comment">// 'object'</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">typeof</span> <span class="hljs-literal">undefined</span>) <span class="hljs-comment">// 'undefined'</span>
</code></pre>
<p>The <code>typeof</code> operator returns the type of the data as a string. The 'number' type represents both integer and float types, the string and boolean represent their respective types.</p>
<p>Arrays, objects, and the <code>null</code> value are of object type, while <code>undefined</code> has its own type.</p>
<h2 id="heading-bitwise-operators">Bitwise Operators</h2>
<p>Bitwise operators are operators that treat their operands as a set of binary digits, but return the result of the operation as a decimal value.</p>
<p>These operators are rarely used in web development, so you can skip this part if you only want to learn practical stuff. But if you're interested to know how they work, then let me show you an example.</p>
<p>A computer uses a binary number system to store decimal numbers in memory. The binary system only uses two numbers, 0 and 1, to represent the whole range of decimal numbers we humans know.</p>
<p>For example, the decimal number 1 is represented as binary number 00000001, and the decimal number 2 is represented as 00000010.</p>
<p>I won't go into detail on how to convert a decimal number into a binary number as that's too much to include in this guide. The main point is that the bitwise operators operate on these binary numbers.</p>
<p>If you want to find the binary number from a specific decimal number, you can Google for the "decimal to binary calculator".</p>
<p>There are 7 types of bitwise operators in JavaScript:</p>
<ol>
<li>AND <code>&amp;</code></li>
<li>OR <code>|</code></li>
<li>XOR <code>^</code></li>
<li>NOT <code>~</code></li>
<li>Left Shift <code>&lt;&lt;</code></li>
<li>Right Shift <code>&gt;&gt;</code></li>
<li>Zero-fill Right Shift <code>&gt;&gt;&gt;</code></li>
</ol>
<p>Let's see how they work.</p>
<h3 id="heading-1-bitwise-and-operator">1. Bitwise AND operator</h3>
<p>The bitwise operator AND <code>&amp;</code> returns a 1 when the number 1 overlaps in both operands. The decimal numbers 1 and 2 have no overlapping 1, so using this operator on the numbers return 0:</p>
<pre><code class="lang-js"><span class="hljs-comment">// 1 = 00000001</span>
<span class="hljs-comment">// 2 = 00000010</span>
<span class="hljs-comment">// ------------</span>
<span class="hljs-comment">//     00000000 = 0</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-number">1</span> &amp; <span class="hljs-number">2</span>); <span class="hljs-comment">// 0</span>
</code></pre>
<h3 id="heading-2-bitwise-or-operator">2. Bitwise OR operator</h3>
<p>On the other hand, the bitwise operator OR <code>|</code> returns all 1s in both decimal numbers.</p>
<pre><code class="lang-js"><span class="hljs-comment">// 1 = 00000001</span>
<span class="hljs-comment">// 2 = 00000010</span>
<span class="hljs-comment">// ------------</span>
<span class="hljs-comment">//     00000011 = 3</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-number">1</span> | <span class="hljs-number">2</span>); <span class="hljs-comment">// 3</span>
</code></pre>
<p>The binary number 00000011 represents the decimal number 3, so the OR operator above returns 3.</p>
<h3 id="heading-bitwise-xor-operator">Bitwise XOR operator</h3>
<p>The Bitwise XOR <code>^</code> looks for the differences between two binary numbers. When the corresponding bits are the same, it returns 0:</p>
<p>5 = 00000101</p>
<pre><code class="lang-js"><span class="hljs-comment">// 5 = 00000101</span>
<span class="hljs-comment">// 7 = 00000111</span>
<span class="hljs-comment">// ------------</span>
<span class="hljs-comment">//     00000010 = 2</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> ^ <span class="hljs-number">7</span>); <span class="hljs-comment">// 2</span>
</code></pre>
<h3 id="heading-bitwise-not-operator">Bitwise NOT operator</h3>
<p>Bitwise NOT <code>~</code> operator inverts the bits of a decimal number so 0 becomes 1 and 1 becomes 0:</p>
<pre><code class="lang-js"><span class="hljs-comment">// 5 = 00000101</span>
<span class="hljs-comment">// ------------</span>
<span class="hljs-comment">//     11111010 = -6</span>

<span class="hljs-built_in">console</span>.log(~<span class="hljs-number">5</span>); <span class="hljs-comment">// -6</span>
</code></pre>
<h3 id="heading-bitwise-left-shift-operator">Bitwise Left Shift operator</h3>
<p>Bitwise Left Shift <code>&lt;&lt;</code> shifts the position of the bit by adding zeroes from the right.</p>
<p>The excess bits are then discarded, changing the decimal number represented by the bits. See the following example:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> &lt;&lt; <span class="hljs-number">2</span>);

<span class="hljs-comment">// 5 = 00000101</span>
<span class="hljs-comment">// ------------ &lt;&lt; Shift to the left by 2</span>
<span class="hljs-comment">//     00010100 = 20</span>
</code></pre>
<p>The right operand is the number of zeroes you will add to the left operand.</p>
<h3 id="heading-bitwise-right-shift-operator">Bitwise Right Shift operator</h3>
<p>Bitwise Right Shift <code>&gt;&gt;</code> shifts the position of the bits by adding zeroes from the left. It's the opposite of the Left Shift operator:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> &gt;&gt; <span class="hljs-number">2</span>); <span class="hljs-comment">// 1</span>

<span class="hljs-comment">// 5 = 00000101</span>
<span class="hljs-comment">// ------------ &gt;&gt; Shift to the right by 2</span>
<span class="hljs-comment">//     00000001 = 1</span>
</code></pre>
<h3 id="heading-bitwise-zero-fill-right-shift-operator">Bitwise Zero-fill Right Shift operator</h3>
<p>Also known as Unsigned Right Shift operator, the Zero-fill Right Shift <code>&gt;&gt;&gt;</code> operator is used to shift the position of the bits to the right, while also changing the sign bit to <code>0</code>.</p>
<p>This operator transforms any negative number into a positive number, so you can see how it works when passing a negative number as the left operand:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-number">-70</span> &gt;&gt; <span class="hljs-number">1</span>); <span class="hljs-comment">// -35</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">-70</span> &gt;&gt;&gt; <span class="hljs-number">1</span>); <span class="hljs-comment">// 2147483613</span>

<span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> &gt;&gt; <span class="hljs-number">1</span>); <span class="hljs-comment">// 2</span>
<span class="hljs-built_in">console</span>.log(<span class="hljs-number">5</span> &gt;&gt;&gt; <span class="hljs-number">1</span>); <span class="hljs-comment">// 2</span>
</code></pre>
<p>In the above example, you can see that the <code>&gt;&gt;</code> and <code>&gt;&gt;&gt;</code> operators return different results. The Zero-fill Right Shift operator has no effect when you use it on a positive number.</p>
<p>Now you've learned how the bitwise operators work. If you think they are confusing, then you're not alone! Fortunately, these operators are scarcely used when developing web applications.</p>
<p>You don't need to learn them in depth. It's enough to know what they are.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this tutorial, you've learned the 7 types of JavaScript operators: Arithmetic, assignment, comparison, logical, ternary, typeof, and bitwise operators.</p>
<p>These operators can be used to manipulate values and variables to achieve a desired outcome.</p>
<p>Congratulations on finishing this guide!</p>
<p>If you enjoyed this article and want to take your JavaScript skills to the next level, I recommend you check out my new book <em>Beginning Modern JavaScript</em> <a target="_blank" href="https://www.amazon.com/dp/B0CQXHMF8G">here</a>.</p>
<p><a target="_blank" href="https://www.amazon.com/dp/B0CQXHMF8G"><img src="https://www.freecodecamp.org/news/content/images/2024/01/beginning-js-cover.png" alt="beginning-js-cover" width="600" height="400" loading="lazy"></a></p>
<p>The book is designed to be easy to understand and accessible to anyone looking to learn JavaScript. It provides a step-by-step gentle guide that will help you understand how to use JavaScript to create a dynamic application.</p>
<p>Here's my promise: <em>You will actually feel like you understand what you're doing with JavaScript.</em></p>
<p>Until next time!</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
