codescracker


javascript

JavaScript Comparison and Logical Operator



« Previous Tutorial Next Tutorial »


JavaScript Comparison and Logical Operators

JavaScript comparison and logical operators are basically used to test for true or false.

JavaScript Comparison Operators

JavaScript comparison operators are basically used in logical statements which is to determine the equality or difference between variables or values. The following table lists the comparison operators available in JavaScript:

Operator Name
== equal to
=== equal value and equal type
!= not equal
!== not equal value or not equal type
< less than
> greater than
<= less than or equal to
>= greater than or equal to

How to use Comparison Operators in JavaScript

JavaScript comparison operators can be used in conditional statements to compare the values and takes actions depending upon the result. Here is an example:

if (marks > 90) 
	text = "Excellent";

JavaScript Logical Operators

JavaScript logical operators are used to determine the logic between the variables or values. The following table lists the logical operators available in JavaScript:

Operator Name
|| or
&& and
! not

« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test