Photo by Sincerely Media on Unsplash
Overview of 2 most Basic JavaScript Operators that every Developer must know about.
In JavaScript, an operator is a special symbol used to perform various operations on values
Operators in JavaScript that I am going to discuss are
- Arithmetic Operators
- Assignment Operator
- Arithmetic Operators
They are just pretty basic operators like we use in Maths
- Addition use to add two numbers e.g 2+2 equals 4
Subtraction use to find difference e.g 2-2 equals 0
Multipication use to find the product of two numbers e.g 2*3 equals 6
Division use to divide two values e.g 10 / 5 equals 2
Modulus It is used to returns the number of times one number fits into the other. e.g 10%4 equals 2
Increment It is used to increase a value by 1 e.g h++ equals to h+1
Decrement It is used to decrease a value by 1 e.g h-- equals to h-1
- Assignment Operator
Assignment operators assign a value to a variable.
= it is used to assign value e.g x = y
+= it is used to add first value in second one to make them equal e.g x += y means x = x + y
-= it is used to subtract first value in second one to make them equal e.g x -= y means x = x - y
= it is used to multiply first value in second one to make them equal x = y means x = x * y
/= it is used to divide first value in second one to make them equal e.g x /= y means x = x / y
- %= it is used as a modulus operator to equate to other value x %= y x = x % y
Let me know if you like it by following You can also reach me at my twitter (at)aishthecoder
Regards, Aish The Coder