JavaScript Operators: The Basics You Need to Know
INTRODUCTION; so people out there you noticed that when ever we write a code in any language (java,python,c++,c) we use various analytical techniques ... ok what are they ..... you noticed comparison,addition, logical comparison javascript make this analytics workable by providing operators. soo yeah in this article we will discuss about operators with examples
WHAT ARE OPERATORS?
in javascript , operators are basically symbol that performs operation on variable or values by using operands.
for example;
here we can see result is a variable in which we are storing operands(5,3) with operator(+).
yeah i do like it man
1.ARITHMETIC OPERATORS:-
Arithmetic operators in JavaScript are just like the math moves you already know.
They help us perform basic calculations like adding numbers, subtracting, multiplying, dividing, and finding the remainder.”
for more extreme cases people have doubt what % do it actually provide u remainder.
2.COMPARISION OPERATOR
these are the operator which compares the value and return boolean functionality like true or false .
| Operator | Meaning |
|---|---|
| == | Equal value |
| === | Equal value and data type |
| != | Not equal |
| > | Greater than |
| < | Less than |
in this example we can clearly se comparing only value and
=== comparing datatype,value
3.LOGICAL OPERATOR:-
Logical operators are used to combine or modify conditions in JavaScript. They help the program make decisions by checking whether multiple conditions are true or false.
Think of them as decision makers that help your code answer questions like:
Should both conditions be true?
Is at least one condition true?
Should the result be the opposite?
so the ouput will be true ,true ,false
age > 18 && hasID→ true
Both conditions are true.age < 18 || hasID→ true
One condition (hasID) is true.!hasID→ false
The NOT operator reverses the value of true
4.ASSIGNMENT OPERATOR:-
Assignment operators are used to assign values to variables in JavaScript.
They help store data in a variable and also allow us to update or modify the value easily*.*
lets for example
let x=10;
if we console log this one u can easily be found output will be 10
let x+=10
here we used += a it simply sayes ki x=x+10;
if we console out that particular thing answer would be 20.
| Operator | Meaning | Example |
|---|---|---|
= |
Assign value | x = 5 |
+= |
Add and assign | x += 3//result=x+3 |
-= |
Subtract and assign | x -= 2//result=x-3 |
*= |
Multiply and assign | x *= 2//result=x*2 |
/= |
Divide and assign | x /= 2//result=x/2 |
here output will be 15;
here output will be 7.
here output will be 20 x*2;
here output will be 5 because x/2.

