Basic Operators

Operator are symbols that can change value.

  • Addition(+)
  • Subtraction(-)
  • Multiplication(*)
  • Division(/)
  • Remainder(%)
  • Exponentioal(+)
  • Comma(,)

Understing terms

Operands

Operands are values on which operator is appied on.

eg-

21+20
- here 21 and 22 are operand

Operator are of two different types.

  • Unary Operand
  • Binary Operand

Unary Operator

The operator that apply on one thing known as Unary operator.

  • Unary operator han one operand.

eg-

-5,5++

Binary Operator

The operator that apply on two things known as Binary operator.

  • Binary operator has two oprand.

eg-

21+10, 100-10

Addition Operator

  • it is used like unary or binary operator.
  • adding two or more numbers.
  • concatenating two or more strings.
  • unary numeric conversion.
  • addition operator behaves diffrently based on value.
  • the addtion operator also be used for converting any other type into a number type.

eg-

12+100
112

"Hello" + "Arya"
HelloArya

Number("21")
21

+"21"
21

+true
1

+false
0

Subtraction Operator

  • subtracting value from another.
  • subtraction operator also used as unary operator.

eg-

100-10
90

"Hello" - "world"
NaN

-12(when you don`t use this operator the value is positive 
value and when you use it becomes nagative value.)

Multiplication Operator

  • multiplication operator can multiply two number.

eg-

100 *0
0

Division Operator

  • division operator gives the result of dividing one number by another.

eg-

12/100
1.2

Remainder Operator

  • This operator also known as modulus operator.
  • Remainder operator is used to find the remainder while dividing A/B.

eg-

10%3
1

100%30
10

Exponential Operator

  • we used double star(**) for exponential operator
  • it`s works like to find square,cube etc.

eg-

 2**3(here ecponential operator do it multiplies 2 by itself 3 times like 2*2*2)
8

Comma Operator

It is the rerest operator but very useful operator

  • comma operator pass multiple value seprated by comma.

eg-

 12,23,400(comma prints the last value)
400

"Hello",21,true
true