<?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"><channel><title><![CDATA[JavaScript Operators: The Basics You Need to Know]]></title><description><![CDATA[JavaScript Operators: The Basics You Need to Know]]></description><link>https://jsoperatorsneedtoknow.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 19 Sep 2026 19:39:15 GMT</lastBuildDate><atom:link href="https://jsoperatorsneedtoknow.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[JavaScript Operators]]></title><description><![CDATA[JavaScript Operators

1. What Are Operators? 🤔
An operator is a symbol that tells the program to perform an operation on values.
Example:
let result = 5 + 3;

Here:
5 and 3 → operands
+ → operator

T]]></description><link>https://jsoperatorsneedtoknow.hashnode.dev/javascript-operators</link><guid isPermaLink="true">https://jsoperatorsneedtoknow.hashnode.dev/javascript-operators</guid><category><![CDATA[Cohort2026]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Raj Singh]]></dc:creator><pubDate>Sun, 15 Mar 2026 05:46:58 GMT</pubDate><content:encoded><![CDATA[<h1>JavaScript Operators</h1>
<hr />
<h1>1. What Are Operators? 🤔</h1>
<p>An <strong>operator</strong> is a symbol that tells the program to <strong>perform an operation on values</strong>.</p>
<p>Example:</p>
<pre><code class="language-javascript">let result = 5 + 3;
</code></pre>
<p>Here:</p>
<pre><code class="language-plaintext">5 and 3 → operands
+ → operator
</code></pre>
<p>The <code>+</code> operator <strong>adds the numbers together</strong>.</p>
<p>Output:</p>
<pre><code class="language-plaintext">8
</code></pre>
<hr />
<h1>2. Arithmetic Operators ➕➖✖️➗</h1>
<p>Arithmetic operators perform <strong>basic mathematical calculations</strong>.</p>
<table>
<thead>
<tr>
<th>Operator</th>
<th>Meaning</th>
<th>Example</th>
</tr>
</thead>
<tbody><tr>
<td>+</td>
<td>Addition</td>
<td>5 + 3</td>
</tr>
<tr>
<td>-</td>
<td>Subtraction</td>
<td>10 - 4</td>
</tr>
<tr>
<td>*</td>
<td>Multiplication</td>
<td>3 * 4</td>
</tr>
<tr>
<td>/</td>
<td>Division</td>
<td>12 / 3</td>
</tr>
<tr>
<td>%</td>
<td>Modulus (remainder)</td>
<td>10 % 3</td>
</tr>
</tbody></table>
<h3>Example in JavaScript</h3>
<pre><code class="language-javascript">let a = 10;
let b = 3;

console.log(a + b);
console.log(a - b);
console.log(a * b);
console.log(a / b);
console.log(a % b);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">13
7
30
3.333...
1
</code></pre>
<p>Explanation:</p>
<pre><code class="language-plaintext">10 % 3 = 1
</code></pre>
<p>Because <strong>3 goes into 10 three times with remainder 1</strong>.</p>
<hr />
<h1>3. Comparison Operators 🔍</h1>
<p>Comparison operators <strong>compare two values</strong> and return <strong>true or false</strong>.</p>
<table>
<thead>
<tr>
<th>Operator</th>
<th>Meaning</th>
<th>Example</th>
</tr>
</thead>
<tbody><tr>
<td>==</td>
<td>Equal value</td>
<td>5 == "5"</td>
</tr>
<tr>
<td>===</td>
<td>Equal value and type</td>
<td>5 === "5"</td>
</tr>
<tr>
<td>!=</td>
<td>Not equal</td>
<td>5 != 3</td>
</tr>
<tr>
<td>&gt;</td>
<td>Greater than</td>
<td>10 &gt; 5</td>
</tr>
<tr>
<td>&lt;</td>
<td>Less than</td>
<td>4 &lt; 8</td>
</tr>
</tbody></table>
<h3>Example</h3>
<pre><code class="language-javascript">console.log(5 == "5");
console.log(5 === "5");
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">true
false
</code></pre>
<h3>Why?</h3>
<pre><code class="language-plaintext">5 == "5"  → only compares values
5 === "5" → compares value AND type
</code></pre>
<p>So:</p>
<pre><code class="language-plaintext">5 == "5"  → true
5 === "5" → false
</code></pre>
<p>Because <code>"5"</code> is a <strong>string</strong>, not a number.</p>
<hr />
<h1>4. Logical Operators 🔗</h1>
<p>Logical operators combine <strong>multiple conditions</strong>.</p>
<table>
<thead>
<tr>
<th>Operator</th>
<th>Meaning</th>
</tr>
</thead>
<tbody><tr>
<td>&amp;&amp;</td>
<td>AND</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td>!</td>
<td>NOT</td>
</tr>
</tbody></table>
<h3>AND Operator (&amp;&amp;)</h3>
<p>Returns <strong>true only if both conditions are true</strong>.</p>
<pre><code class="language-javascript">let age = 20;

console.log(age &gt; 18 &amp;&amp; age &lt; 30);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">true
</code></pre>
<p>Because <strong>both conditions are true</strong>.</p>
<hr />
<h3>OR Operator (||)</h3>
<p>Returns <strong>true if at least one condition is true</strong>.</p>
<pre><code class="language-javascript">console.log(5 &gt; 10 || 8 &gt; 3);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">true
</code></pre>
<p>Because <strong>8 &gt; 3 is true</strong>.</p>
<hr />
<h3>NOT Operator (!)</h3>
<p>Reverses a boolean value.</p>
<pre><code class="language-javascript">console.log(!true);
console.log(!false);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">false
true
</code></pre>
<hr />
<h1>Logical Operator Truth Table</h1>
<img src="https://cdn.hashnode.com/uploads/covers/696e2a8b7dae68d21267b05d/ed0a6a9a-d702-4fc0-a79d-bd50455c2b6a.png" alt="" style="display:block;margin:0 auto" />

<hr />
<h1>5. Assignment Operators 📝</h1>
<p>Assignment operators <strong>assign values to variables</strong>.</p>
<table>
<thead>
<tr>
<th>Operator</th>
<th>Example</th>
<th>Meaning</th>
</tr>
</thead>
<tbody><tr>
<td>=</td>
<td>x = 5</td>
<td>Assign value</td>
</tr>
<tr>
<td>+=</td>
<td>x += 3</td>
<td>x = x + 3</td>
</tr>
<tr>
<td>-=</td>
<td>x -= 2</td>
<td>x = x - 2</td>
</tr>
</tbody></table>
<h3>Example</h3>
<pre><code class="language-javascript">let x = 10;

x += 5;
console.log(x);
</code></pre>
<p>Output:</p>
<pre><code class="language-plaintext">15
</code></pre>
<p>Explanation:</p>
<pre><code class="language-plaintext">x += 5
means
x = x + 5
</code></pre>
<hr />
<h1>Operator Categories Diagram</h1>
<p><img src="align=%22center%22" alt="" /></p>
<hr />
<h1>Assignment Practice 💻</h1>
<p>Try these exercises.</p>
<hr />
<h2>1. Perform Arithmetic Operations</h2>
<pre><code class="language-javascript">let a = 12;
let b = 4;

console.log(a + b);
console.log(a - b);
console.log(a * b);
console.log(a / b);
</code></pre>
<hr />
<h2>2. Compare Two Values</h2>
<pre><code class="language-javascript">let x = 5;
let y = "5";

console.log(x == y);
console.log(x === y);
</code></pre>
<p>Observe the <strong>difference in output</strong>.</p>
<hr />
<h2>3. Use Logical Operators</h2>
<pre><code class="language-javascript">let age = 22;

if (age &gt; 18 &amp;&amp; age &lt; 60) {
  console.log("You are eligible to work");
}
</code></pre>
<hr />
]]></content:encoded></item></channel></rss>