<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Edward Benedict on Medium]]></title>
        <description><![CDATA[Stories by Edward Benedict on Medium]]></description>
        <link>https://medium.com/@edwardbenedict92?source=rss-8299c279709b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OyqNGZgU88eGRubTzzAjVA.png</url>
            <title>Stories by Edward Benedict on Medium</title>
            <link>https://medium.com/@edwardbenedict92?source=rss-8299c279709b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 13:25:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@edwardbenedict92/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[JavaScript Operators]]></title>
            <link>https://medium.com/@edwardbenedict92/javascript-operators-aed7c77c3b6c?source=rss-8299c279709b------2</link>
            <guid isPermaLink="false">https://medium.com/p/aed7c77c3b6c</guid>
            <category><![CDATA[operators]]></category>
            <category><![CDATA[web-developer]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Edward Benedict]]></dc:creator>
            <pubDate>Mon, 28 Sep 2020 11:51:29 GMT</pubDate>
            <atom:updated>2020-09-28T11:51:29.745Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Javascript" src="https://cdn-images-1.medium.com/max/1024/0*0CB7alFxYDcGB8dc" /></figure><h3><strong>Purpose of the this article training is to teach the reader JavaScript Operators.</strong></h3><h3>1. JavaScript Assignment Operators</h3><ul><li>We can define new variables and use assignment operators.</li></ul><pre>let x = 2;<br>const y = 3;<br><br>console.log(x);<br>// expected output: 2<br><br>console.log((x = y + 1)); // 3 + 1<br>// expected output: 4<br><br>console.log((x = x * y)); // 4 * 3<br>// expected output: 12</pre><p>Operator : x = y</p><h3>2. Adding assignment operator(+)</h3><ul><li>The addition assignment operator (+=) adds the value of the right operand to a variable and assigns the result to the variable.</li></ul><pre>let a = 2;<br>let b = &quot;hello&quot;;<br><br>console.log((a += 3)); // addition<br>// expected output: 5<br><br>console.log((b += &quot; world&quot;)); // concatenation<br>// expected output: &quot;hello world&quot;</pre><h3>3 . Subtraction assignment operator(-)</h3><ul><li>The subtraction assignment operator (-=) subtracts the value of the right operand from a variable and assigns the result to the variable.</li></ul><pre>let a = 2;<br><br>console.log((a -= 3));<br>// expected output: -1<br><br>console.log((a -= &quot;Hello&quot;));<br>// expected output: NaN</pre><p>Operator : x -= y<br>Meaning : x = x-y</p><h3>4 . Multiplication assignment operator(*)</h3><ul><li>The multiplication assignment operator (*=) multiplies a variable by the value of the right operand and assigns the result to the variable.</li></ul><pre>let a = 2;<br><br>console.log((a *= 3));<br>// expected output: 6<br><br>console.log((a *= &quot;hello&quot;));<br>// expected output: NaN</pre><p>Operator : x *= y<br>Meaning : x = x *y</p><h3>5. Division assignment operator(/)</h3><ul><li>The division assignment operator (/=) divides a variable by the value of the right operand and assigns the result to the variable.</li></ul><pre>let a = 3;<br><br>console.log((a /= 2));<br>// expected output: 1.5<br><br>console.log((a /= 0));<br>// expected output: Infinity<br><br>console.log((a /= &quot;hello&quot;));<br>// expected output: NaN</pre><p>Operator : x /= y<br>Meaning : x = x / y</p><h3>6. Adding Strings and Numbers</h3><ul><li>Adding two numbers, will return the sum, but adding a number and a string will return a string:</li></ul><pre>var x = 5 + 5;<br>// expected output: 10<br><br>var y = &quot;5&quot; + 5;<br>// expected output: 55<br><br>var z = &quot;Hello&quot; + 5;<br>// expected output: Hello5</pre><p>❗ If you add a number and a string, the result will be a string!</p><h3>7. Remainder assignment operator(%=)</h3><ul><li>The remainder assignment operator (%=) divides a variable by the value of the right operand and assigns the remainder to the variable.</li></ul><pre>let a = 3;<br><br>console.log((a %= 2));<br>// expected output: 1<br><br>console.log((a %= 0));<br>// expected output: NaN<br><br>console.log((a %= &quot;hello&quot;));<br>// expected output: NaN</pre><p>Operator : x %= y</p><p>Meaning : x = x % y</p><h3>8. Exponentiation assignment (**=)</h3><ul><li>The exponentiation assignment operator (**=) raises the value of a variable to the power of the right operand.</li></ul><pre>let a = 3;<br><br>console.log((a **= 2));<br>// expected output: 9<br><br>console.log((a **= 0));<br>// expected output: 1<br><br>console.log((a **= &quot;hello&quot;));<br>// expected output: NaN</pre><p>Operator : x **= y</p><p>Meaning : x = x ** y</p><h3>9. Logical AND assignment (&amp;&amp;=)</h3><ul><li>The logical AND assignment (x &amp;&amp;= y) operator only assigns if x is truthy.</li></ul><pre>let a = 1;<br>let b = 0;<br><br>a &amp;&amp;= 2;<br>console.log(a);<br>// expected output: 2<br><br>b &amp;&amp;= 2;<br>console.log(b);<br>// expected output: 0</pre><p>Syntax :</p><pre>expr1 &amp;&amp;= expr2;</pre><p>Using Logical AND Assignment</p><pre>let x = 0;<br>let y = 1;<br><br>x &amp;&amp;= 0; // 0<br>x &amp;&amp;= 1; // 0<br>y &amp;&amp;= 1; // 1<br>y &amp;&amp;= 0; // 0</pre><h3>10. Logical OR assignment (||=)</h3><ul><li>The logical OR assignment (x ||= y) operator only assigns if x is falsy.</li></ul><pre>const a = { duration: 50, title: &quot;&quot; };<br><br>a.duration ||= 10;<br>console.log(a.duration);<br>// expected output: 50<br><br>a.title ||= &quot;title is empty.&quot;;<br>console.log(a.title);<br>// expected output: &quot;title is empty&quot;</pre><p>Syntax :</p><pre>expr1 ||= expr2;</pre><p>Example:</p><pre>x || y;<br>// returns x when x is truthy<br>// returns y when x is not truthy</pre><ul><li>If the “content” element is empty, set the innerHTML to a default value:</li></ul><pre>document.getElementById(&quot;content&quot;).innerHTML ||= &quot;&lt;i&gt;No content.&lt;/i&gt;&quot;;</pre><h3>11. Logical nullish assignment (??=)</h3><ul><li>The logical nullish assignment (x ??= y) operator only assigns if x is nullish (null or undefined).</li></ul><pre>const a = { duration: 50 };<br><br>a.duration ??= 10;<br>console.log(a.duration);<br>// expected output: 50<br><br>a.speed ??= 25;<br>console.log(a.speed);<br>// expected output: 25</pre><p>Syntax :</p><pre>expr1 ??= expr2;</pre><ul><li>Using logical nullish assignment</li></ul><pre>function config(options) {<br>  options.duration ??= 100;<br>  options.speed ??= 25;<br>  return options;<br>}<br><br>config({ duration: 125 }); // { duration: 125, speed: 25 }<br>config({}); // { duration: 100, speed: 25 }</pre><h3>12. JavaScript Typeof Operator</h3><ul><li>You can use the typeof operator to find the data type of a JavaScript variable.</li></ul><p>Syntax :</p><pre>typeof variable;</pre><p>Example :</p><pre>typeof &quot;John&quot;;<br>// expected output: &quot;string&quot;<br><br>typeof 3.14;<br>// expected output: &quot;number&quot;<br><br>typeof NaN;<br>// expected output: &quot;number&quot;<br><br>typeof false;<br>// expected output: &quot;boolean&quot;<br><br>typeof [1, 2, 3, 4];<br>// expected output: &quot;object&quot;<br><br>typeof { name: &quot;John&quot;, age: 34 };<br>// expected output: &quot;object&quot;<br><br>typeof new Date();<br>// expected output: &quot;object&quot;<br><br>typeof function () {};<br>// expected output: &quot;function&quot;<br><br>typeof myCar;<br>// expected output: &quot;undefined&quot;<br><br>typeof null;<br>// expected output: &quot;object&quot;</pre><p>I hope you have enjoyed and learned JavaScript Operators.</p><p>Happy coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aed7c77c3b6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>