JavaScript getDate
Javascript Infinity
JavaScript undefined
JavaScript eval function
JavaScript uneval function
Javascript isFinite function
Javascript isNaN functions
Javascript parseFloat functions
Javascript parseInt functions
Javascript decodeURI functions
Javascript decodeURIComponent functions
Javascript encodeURI functions
Javascript encodeURIComponent functions
Javascript escape functions
Javascript unescape functions
Javascript Objects
Javascript Number
JavaScript Date object
JavaScript Math Object
JavaScript Array
Javascript Comments
JavaScript Data types
JavaScript special characters
JavaScript if condition
Javascript For Loop
JavaScript While Statement
JavaScript Switch Case statement
JavaScript Exception handling
JavaScript do while statement
JavaScript label statement
JavaScript break statement
JavaScript continue statement
JavaScript for in statement
JavaScript function
JavaScript Assignment operators
JavaScript Comparison operators
Javascript Arithmetic operators
JavaScript Bitwise operators
JavaScript Logical operators
JavaScript String operators
JavaScript Conditional operators
JavaScript typeof operator
JavaScript void operator
JavaScript toExponential functional
JavaScript toFixed function
JavaScript toPrecision function
JavaScript charCodeAt function
JavaScript concat function
JavaScript fromCharCode function
JavaScript indexOf function
JavaScript lastIndexOf function
JavaScript localeCompare function
JavaScript match function
JavaScript replace function
JavaScript search function
Javascript slice function
JavaScript split function
JavaScript substr function
JavaScript substring function
JavaScript toLocaleLowerCase function
JavaScript toLocaleUpperCase function
Javascript toString function
JavaScript trim function
JavaScript valueOf function
JavaScript pop function
JavaScript push function
JavaScript shift function
JavaScript unshift function
JavaScript sort function
JavaScript reverse function
6 Example(s) of JavaScript Logical operators
Description :
Logical Operator <
, >
evaluates the expression and return true or false.
JavaScript Logical operators Example - 1
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p id="sample"></p>
<script>
var x = 9;
var y = 3;
document.getElementById("sample").innerHTML =
(x < 10 && y > 1) + "<br>" +
(x < 10 && y < 1);
</script>
</body>
</html>
Description :
Logical Operator ===
will check for equality using equal value and equal type and return true and false.
JavaScript Logical operators Example - 2
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p id="sample"></p>
<script>
var x = 6;
var y = 3;
document.getElementById("sample").innerHTML =
(x === 5 || y === 5) + "<br>" +
(x === 6 || y === 5) + "<br>" +
(x === 6 || y === 3);
</script>
</body>
</html>
Description :
Logical Operator ===
and >
example
JavaScript Logical operators Example - 3
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p id="sample"></p>
<script>
var x = 6;
var y = 3;
document.getElementById("sample").innerHTML =
!(x === y) + "<br>" +
!(x > y);
</script>
</body>
</html>
Description :
Logical
variables are used with boolean values and will return the boolean
result. See the code snippet:
JavaScript Logical operators Example - 4
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<p id="sample"></p>
<script>
var val1 = 9;
var val2= 3;
document.getElementById("sample").innerHTML =
(val1 < 10 && val2 > 1) + "<br>" +
(val1 < 10 && val2 < 1);
</script>
</body>
</html>
Description :
Here is a code which use ||
operator (val1 === 5 || val2 === 5) will result in false and (val1 === 6 || val2 === 5) will result in true. See the code snippet:
JavaScript Logical operators Example - 5
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<p id="sample"></p>
<script>
var val1 = 6;
var val2 = 3;
document.getElementById("sample").innerHTML =
(val1 === 5 || val2 === 5) + "<br>" +
(val1 === 6 || val2 === 5) + "<br>" +
(val1 === 6 || val2 === 3);
</script>
</body>
</html>
Description :
Example of JavaScript Logical Operator
:
JavaScript Logical operators Example - 6
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<p id="sample"></p>
<script>
var val1 = 6;
var val2 = 3;
document.getElementById("sample").innerHTML =
!(val1 === val2) + "<br>" +
!(val1 > val2);
</script>
</body>
</html>
Please enable JavaScript to view the comments powered by Disqus.