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.

Recent Posts

Google Announces that AI-developed Drug will be in Trials by the End of the Year

Isomorphic Labs, a drug discovery start-up launched four years ago and owned by Google’s parent…

4 hours ago

Instagram Extends Reels Duration to 3 Minutes

Regardless of whether TikTok faces a U.S. ban, Instagram is wasting no time positioning itself…

2 days ago

AWS Expands Payment Options for Nigerian Customers, Introducing Naira (NGN) for Local Transactions

Amazon Web Services (AWS) continues to enhance its customer experience by offering more flexible payment…

6 days ago

Why JavaScript Remains Dominant in 2025

JavaScript, often hailed as the "language of the web," continues to dominate the programming landscape…

1 week ago

Amazon Moves to Upgrade Alexa with Generative AI Technology

Amazon is accelerating efforts to reinvent Alexa as a generative AI-powered “agent” capable of performing…

1 week ago

Smuggled Starlink Devices Allegedly Used to Bypass India’s Internet Shutdown

SpaceX's satellite-based Starlink, which is currently unlicensed for use in India, is reportedly being utilized…

1 week ago