Logical Operators In Java Script

Logical operators are used to perform Boolean operations on operands. Logical operators are and (&&), or ( || ) , not (!) . The value returned after using a logical operator is Boolean value true or false. Logical operators are connectors of expressions also.
 
Operator Description
&& Both the expression should be correct then it returns true else it returns false. It is known as “and” operator
|| If Any of the given expressions is found true then it returns true else it returns false.
! If the given expression is true it returns false and if given expression is false it returns true.

 

 
Example
 
<html>

<head>

</head>

<body>

<script>

var a=9

var b=8

var c=25

document.write(“<br> a is : “+a)

document.write(“<br> a is : “+b)

document.write(“<br> a is : “+c)

document.write(“<br>is a greater than b and greater c also ? : “+(a>b && a>c)) document.write(“<br>is a greater than b or greater c ? : “+(a>b || a>c)) document.write(“<br>not c is greater than a ? : “+!(c>a))

</script>

</body>

</html>

 
Output:
 
a is : 9
a is : 8
a is : 25
is a greater than b and greater c also ? : false
is a greater than b or greater c ? : true
not c is greater than a ? : false