Javascript Operators – Example Logical and Comparison Operators

In JavaScript two types of Operators are used to perform specific task.

Arithmetic and Assignment operator.

Arithmetic Operators:

The Arithmetic operators are (+ , – , * , / ) to compute or manipulate values.

Example:

<!DOCTYPE html>
<html>
<body>
<h2>Arithmetic and Assignment Opertor Example</h2>
<p>The = operator used to assign values and (+) Operator to add two Values</p>
<p id="darkweb"></p>
<script>
var x, y;
x = 4;
y = 8;
document.getElementById("darkweb").innerHTML = x + y;
</script>
</body>
</html>

JavaScript Operators

In JavaScript there are two types of operators  i.e. Arithmetic operators & Assignment Operators.

Arithmetic Operators:

There are some Arithmetic operators in below table:

OperatorsDescription
+Addition
Subtraction
*Multiplication
**Exponentiation
/Division
%Modulus/Remainder
++Increment
Decrement

Assignment Operator in JavaScript:

These are the following Assignment Operators in JS.

OperatorExample
=A=B
+=A+=B
-=A-=B
*=A*=B
/=A/=B
%=A%=B
**=A**=B

JavaScript Comparison Operators:

These are the following comparison operators in JS:

OperatorDescription
==Equal to
===Equal value & Equal Type
!=Not equal
!==Not equal value or not equal  type
Greater than
Less than
>=Greater than equal to
<=Less than equal to
?Ternary operator

Stay in touch. Ask Questions.
Lean on us for help, strategies and expertise.

Leave a Reply

Your email address will not be published. Required fields are marked *