Hi guys,
Today i learned Java Script Arithmetic Operators.
The topic is very interesting, so i'll discuss the Arithmetic Operators.
- what is arithmetic operators ?
In JavaScript, arithmetic operators are symbols used to perform basic mathematical operations on numeric values.
classification of the Arithmetic Operators:
operators :
+ Addition/concatenation
- Subtraction
* Multiplication
/ Division
% Modules(remainder)
** Exponentiation(power)
++ Increment by 1
-- Decrement by 1
- what is concatenation ?
String concatenation in JavaScript refers to the process of combining two or more strings into a single string.
example:
**input:**
let i="200"+6;
let i++:
console.log(i);
**output:**
2006
- Increment and Decrement
There are two types,
- prefix form (First increments and decrement of the variable. Then the updated value)
[eg; increment
let x=7;
++x;
console.log(x); ] // 7 // 8
[decrement
let x=7;
--x;
console.log(x); ] //7 //6
- postfix form (Returns the original value first. Then the modified the variable)
`[eg;increment
let x=7;
x++;
console.log(x);] //7 //8]
decrement
let x=7;
x--;
console.log(x); ] //7 //6`
I Hope, this blog is helpfull for anyone and helpfull myself.
Thankyou.
Top comments (3)
Good writing! Keep it up
Ok, Thank you.
Nice recap! The way + works for both numbers and strings in JavaScript can be confusing at first. Did you find any surprises when playing around with these operators?