Arithmetic Vs Comparison Operator – JavaScript Tutorial
Arithmetic and Comparison Operator. In this article, we will take a brief look at Operators in JavaScript. But first, before we move on we need understand what is an operator. So let us first start this article from the operator and end up with the comparison operator. We mostly use the operator to specify our expressions because using operators you can compare two values you can add multiply divide and do so many things.
now the question is what is the operator? In simple words operator is just an expression result in a value. Operators take one or more operands to produce a result. For example, In this example, i will say 1 + 2. Nowhere 1 and 2 is operands and Plus sign is an operator. in the programming language, you often see operand called argument.
So we will start our operators from basic mathematics. Now let me move on to the arithmetic and comparison operator. So we’ll discuss arithmetic operator first. As long as I know you feel comfortable with arithmetic operator because you learned most of them in the school.
Arithmetic Operator

( + ) Addition
 Addition is use for addition and also for concatenation.
 For Example,
12345//3 + 2 = 5; // add two values//  this operator evaluates value right to left.
 For Example,
 Addition is use for addition and also for concatenation.

( – ) Subtraction
 Subtraction used to subtract two values.
 For Example,
12345//3  2 = 1 // subtract 2 from value 3;//
this operator evaluates value right to left.
 For Example,
 Subtraction used to subtract two values.

( / ) Division
 The division Operator used to divide two values.
 For Example,
12345//3/2 = 1.5 // devide two values// this operator evaluate value left to right
 For Example,
 The division Operator used to divide two values.

( * ) Multiplication
 The multiplication use to multiply two values.
 For Example,
12345//3 * 2 = 6 // Multiply two values// this operator evaluates value left to right

( % ) Reminder
 Reminder return reminder after division.
 For Example,
12345//10 % 3 = 1 // so 3 goes into 10 three times, and with 1 left over// this operator evaluates value left to right.

( – ) Unary Negation
 Unary negation use to specify the negative value.
 For example, It means if y is equal to 10 then y will be 10
 This operator evaluates the value right to left.

( + ) Unary Plus
 Unary negation use to specify the Positive value.
 For example, It means if y is equal to 10 then +y will be 10
 This operator evaluates the value right to left

( ++ ) Preincrement
 ++y Used to increment the value by one add evaluate to a new value.
 This operator evaluates the value right to left
 For example,
12345678910//let j,x = 5;j = ++x; // pre incrementconsole.log(j); will be 6//

( ++ ) Postincrement
 y++ Used to increment the value by one.
 This operator evaluates the value right to left
 For example,
123456789101112131415//let j,x = 5;j = x++; // post incrementconsole.log(j); wil be 5J = x++;cosol.log(j) will be 6//

( — ) Predecrement
 –y use to decrease the value by one. And evaluate to a new value.
 This operator evaluates the value right to left.

( — ) Postdecrement
 y– used to decrease the value by one. Evaluate to the value of y before the increment.
 This operator evaluates the value right to left.
Comparison Operator
As the name implies, Comparison operator compares two different values. Broadly speaking there are three types of the comparison operator. Strict equality abstract equality and relational equality. We will take a look at all these three types in the next tutorial but now just take a look how comparison operator looks like.
So the following is the comparison operator to compare two different values.

( < ) Less Then
 less than operator evaluates to true if its first operand is less than its second operand. Otherwise, it evaluates to false. Less than operator evaluate to value left to right.
 For example,
123456//Let x = 5, y = 10;console.log(x < y) the result would be true//

( > ) Greater Than
 Greater than operator evaluates to true if its first operand is greater than its second operand. Otherwise, it evaluates true false. Greater than operator evaluates to value left to right.
 For example,
123456//let x = 5, y = 10;console.log(x > y) the result would be false//

( <= ) Less Than or Equal
 So less than or equal to operator evaluates to true if Its first or brand is less than or equal to its a second or operand. Otherwise, it evaluates to false. Less than or equal to evaluate to value left to right.
 For example,
12345678910//let x = 5, y = 10;console.log(x <= y) the result would be true// If i just say hereconsole.log(x <= 5) the result would be true// And if i sayconsole.log(x <= 3) the result would be false//

( <= ) Greater Than or Equal
 Greater than or equal to operator evaluate to true if its first operand is greater than or equal to its second operand. Otherwise, it evaluates to false. Greater than or equal to evaluate to value left to right.
 For example,
123456789101112//let x = 5, y = 10;console.log(x >= y) the result would be false// If i just say hereconsole.log(x >= 5) the result would be true// And if i sayconsole.log(x >= 3) the result would be true//
That’s it. Now our Arithmetic and comparison operator is completed. In the next article, we will explore more operators and learn the complete set of javascript operators. So that is all for this article, We will see you in the next article.
Leave a Reply