programming

What are Relational Operators?

Unlike logical operators which connect two or more expressions, relational operators test and establish some type of relation between two or more operands.

There are six (6) relational operators, which are:

  1. Equal to (==)

Yes, I know what you are thinking. We should have used the well-know equal sign (=) right? Well, that falls under arithmetic operators, and in programming it is called the simple assignment operator. The equals operator checks if the values of two operands are equal or not. If yes, the condition becomes true otherwise it becomes false.

//Example
let a, b;
a = 3; b = 4;
console.log(a==b) //FALSE

2. Not Equals (!=)

This also checks if the values of two operands are equal or not. If they are not equal, the condition becomes true otherwise it becomes false.

//Example
let a, b;
a = 3; b = 4;
console.log(a!=b) //TRUE

3. Greater Than (>):

Checks if the value of the left operand is greater than the value of the right operand. If so, the condition becomes true otherwise it returns false.

//Example
let a, b;
a = 3; b = 4;
console.log(a>b) //FALSE

4. Less Than (<):

Checks if the value of the left operand is less than that of the right operand. If so, the condition becomes true, otherwise it returns false.

//Example
let a, b;
a = 3; b = 4;
console.log(a<b) //TRUE

5. Greater Than or Equals (>=)

Checks if the value of the left operand is less than or equal to the right operand. If one of them is true, the condition becomes true, otherwise it returns false.

//Example
let a, b;
a = 3; b = 4;
console.log(a>=b) //FALSE because a is neither greater than or equal to b

6. Less Than or Equals (<=)

Checks if the value of the left operand is less than or equal to the right operand. If yes, the condition becomes true. Otherwise it returns false.

//Example
let a, b;
a = 3; b = 4;
console.log(a<=b) //TRUE because while a is not equal to be, it is certainly less than b

Why you should be interested in software development

THE END.

Author

Recent Posts

Apple is developing a doorbell camera equipped with Face ID technology.

Apple is reportedly developing a new smart doorbell camera with Face ID technology to unlock…

9 hours ago

Google Launches Its Own ‘Reasoning’ AI Model to Compete with OpenAI

This month has been packed for Google as it ramps up efforts to outshine OpenAI…

2 days ago

You can now use your phone line to call ChatGPT when cellular data is unavailable.

OpenAI has been rolling out a series of exciting updates and features for ChatGPT, and…

4 days ago

Phishers use fake Google Calendar invites to target victims

A financially motivated phishing campaign has targeted around 300 organizations, with over 4,000 spoofed emails…

5 days ago

Hackers Exploiting Microsoft Teams to Remotely Access Users’ Systems

Hackers are exploiting Microsoft Teams to deceive users into installing remote access tools, granting attackers…

6 days ago

Ethical Hacking Essentials

Data plays an essential role in our lives.  We each consume and produce huge amounts…

1 week ago