DEV Community

Cover image for Arithmetic Operators in Java Script.
vishnu vishnu
vishnu vishnu

Posted on

Arithmetic Operators in Java Script.

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

Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode

- 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
Enter fullscreen mode Exit fullscreen mode
  • 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`

Enter fullscreen mode Exit fullscreen mode

I Hope, this blog is helpfull for anyone and helpfull myself.

Thankyou.

Top comments (3)

Collapse
 
payilagam_135383b867ea296 profile image
Payilagam

Good writing! Keep it up

Collapse
 
vishnu_vishnu_856744a4421 profile image
vishnu vishnu

Ok, Thank you.

Collapse
 
dotallio profile image
Dotallio

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?