What is an operator?

In simple terms, Operators are like functions that are written in a special way to perform specific functions in JavaScript.. sounds confusing right??? Let's surge ahead to have a better glimpse of what we have in stall.

Types of Operators in JavaScript.

There are different types of Operators in JavaScript, but the scope of this discuss chose to go with three main types namely;

  1. Math(Arithmetic) Operators
  2. Logical Operators
  3. typeOf operators and

Let's take them bit by bit.

What are Math Operators?

I don't think the meaning of this should give us much headache as the keyword (Math) is what we deal with on a daily basis. So Math Operators are the common arithmetic operations that are use to carry out numerical functions e.g (+ - * √) just to mention few.

Examples of Math Operator usage in JS.

var now =2018;
var ageJohn = 28;
var dob;
          ↗️(math operator(-)
dob = now - ageJohn ;
console.log(dob)
//1990 would be parsed to the console.
console.log(now + 2);
console.log(now * 2);
console.log(now/ 10);
/*
2020
4036
201.8
would be logged respectively into the browser console
*/
// NB: Math Operator (+ , - ,  * and / ) were 
//explicitly experimented here

Logical Operators: This simply are the ones used to parse logical arguments to satisfy a condition in order to get desired result based on varying entries.

See example below

// Logical Operators
var johnAge = 33;
var ageMark = 28;
var johnOlder = johnAge > ageMark ;
console.log(johnOlder)
// true
/*
console parsed true because the argument is so as John age(33) is greater than Mark's age(28)
*/

DIY : try replacing the greater than sign to less than and see what will happen. Best of luck.

typeof operators.

These are operators basically used in determining the data types of entries stored in a variable .

NB. You can check JS Data types to know more

See example below.