JavaScript Comparison and Logical Operators

In this tutorial I’m going to learn how to use Comparison and logical operators in laravel. Comparison operators compare two values and give back a boolean value: either true or false. Comparison operators are used in decision making and loops.

OperatorDescriptionExample
==Equal to: true if the operands are equal5==5; //true
!=Not equal to: true if the operands are not equal5!=5; //false
===Strict equal to: true if the operands are equal and of the same type5==='5'; //false
!==Strict not equal to: true if the operands are equal but of different type or not equal at all5!=='5'; //true
>Greater than: true if the left operand is greater than the right operand3>2; //true
>=Greater than or equal to: true if the left operand is greater than or equal to the right operand3>=3; //true
<Less than: true if the left operand is less than the right operand3<2; //false
<=Less than or equal to: true if the left operand is less than or equal to the right operand2<=2; //true

Example 1: Equal to Operator

const a = 5, b = 2, c = 'hello';

console.log(a == 5);     // true
console.log(b == '2');   // true
console.log(c == 'Hello');  // false

Output:-

Not equal to !=

const a = 3,
b = 'hello';
// not equal operator
console.log(a != 2);
console.log(b != 'Hello');

Output:-

Strict equal to

const a = 2;
// strict equal operator
console.log(a === 2); // true
console.log(a === '2');

Output:-

Thanks for reading 👍👍

Hi I am Amit Kumar Thakur Experienced as s Software Developer with a demonstrated history of working in the information technology and services industry. Skilled in HTML, CSS, Bootstrap4, PHP, Laravel-9 , REST API,FB API,Google API, Youtube Api, Bitbucket,Github,Linux and jQuery. Strong engineering professional focused in Computer/Information Technology Administration and Management. Currently my profile is to Software Developer, analyze the requirement, creating frame for web application, coding and maintenance.

Related Posts

How to print Null value Using JavaScript ?

In JavaScript, if you want to print the string “null” when a variable is null, you can do so add in !== operator. Benefits of Using if-else…

How to use Prompt function in JavaScript ?

In this tutorial we’re going to learn how to use Prompt function using JavaScript. Just use below code and put put inside the script tag Output:- I…

How to use JavaScript Constructor Function ?

A JavaScript constructor function is a function that is used to create new objects. It is called a constructor because it constructs new objects. To create a…

How to use Let and Const in JavaScript ?

In this tutorial we’re going to learn how to use Const and let function in JavaScript. JavaScript let is used to declare variables. The variables declared using let are block-scoped. This means…

Top 10 IT Certification in The World ?

In this tutorial I’m going to share top 10 IT Certification in the world who help to grow your carrier in fast way also we ‘having covering…

Phantom installation failed TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string.

Error:- Solutions:- Run this Output :-

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x