Forbrukslån på Dagen | Paras Ulkoinen Kovalevy | Beste Kredittkort | Strømleverandører | Billigste Brannalarm | Billig Forsikring | Billigste Mobilselskaper | Hva er Boligen Verdt
JavaScript programming

Logical Operator JavaScript

JavaScript programming the logical operator (Logical Operator) is used, usually in the value of the variable or logical operations through its two boo lean true or false as a result of taking any of the results are based on, and to perform the operation. Conditional and looping statements to create a logical operator (Logical Operator) play an important role.

Logical operator services

Operator

Operator Name

Example

Results

!

NOT

!a

If the value of a false,! a = true will. To the contrary, the value of the Boolean variables, logical NOT (NOT) operator is used.

&&

AND

a && b

If true of both a and b, a && b would be true for the results.

||

OR

a || b

Both a and b of the at least one variable If true, a || The results will be b true.

Practice Project

<html>
<head>
<title> www.trickbd.com.bd</title>
<style>
body{background: #FFC;
font-size:20px;}
h2{color:#FF0066;}
</style>

</head>
<body>
<script type = “text/javascript”>
document.write(“<h2>Logical NOT Operator </h2>”);
var a = false;
document.write(“<p> A = “+ a + “.</p>”);
var b = !a;
document.write(“<p> B = !A </p>”);
document.write(“<p> B = “+ b + “.</p>”);
</script>
<script type = “text/javascript”>
document.write(“<h2>Logical AND Operator </h2>”);
var c = 15;
var d = 25;
document.write(“<p> C = “+ c + “.</p>”);
document.write(“<p> D = “+ d + “.</p>”);
var p = c < 20;
var q = d > 20;
document.write(“<p>Result of C < 20 is “+ p + “.</p>”);
document.write(“<p>Result of D > 20 is “+ q + “.</p>”);
if( c < 20 && d > 20 ){
document.write(“Result of C < 20 && D > 20 is True . “);
}
else {
document.write(“Result of C < 20 && D > 20 is false . “);
}
</script>
<script type = “text/javascript”>
document.write(“<h2>Logical OR Operator </h2>”);
var e = 20;
var f = 50;
document.write(“<p> E = “+ e + “.</p>”);
document.write(“<p> F = “+ f + “.</p>”);
var x = e < 10;
var y = f > 20;
document.write(“<p>Result of E < 10 is “+ x + “.</p>”);
document.write(“<p>Result of F > 20 is “+ y + “.</p>”);
if( e < 10 || f > 20 ){
document.write(“Result of E < 10 || F > 20 is True . “);
}
else {
document.write(“Result of E < 10 || F > 20 is false . “);
}
</script>
</body>

</html>

Notepad to open a file type from the menu at the top of layer code by clicking on the Save as File name: index.html, Save as type: All files, save and open the index.html file with the Mozilla Firefox look like the image shown below.

  • At the top of the program var a = false; The value of a variable is set to false. var b =! a; The logical NOT (NOT) operation has been performed. The browser displays a variable browser will display false. b variable browser, the browser displays the true will be displayed.
  • var c = 15; And var d = 25; So var p = c <20; In the case of c <20 should be adopted as a result of variable p is true. p variable document.write ( “<p> Result of C <20 is” + p + “. </ p>”); By the browser, the browser displays the Result of C <20 is true. Will be displayed. Uncrushable var var q = d> 20; In the case of d> 20 the results will be accepted as the true value of the variable q. q variable document.write ( “<p> Result of D> 20 is” + q + “. </ p>”); by the browser, the browser displays the Result of D> 20 is true. Will be displayed. So true && true true since the results of the c <20 && d> 20 the results true. And the browser Result of C <20 && D> 20 is True. Is displayed.
  • var var e = 20; And var var f = 50; So var var x = e <10; In the case of e <10; The result will be taken as the value of the variable x, which is false. x variable document.write ( “<p> Result of E <10 is” + x + “. </ p>”); By the browser, the browser displays the Result of E <10 is false. Will be displayed. Uncrushable var y = f> 20; In the case of f> 20, which is true for the results to be accepted as a variable q. y variable document.write ( “<p> Result of F> 20 is” + y + “. </ p>”); by the browser, the browser displays the Result of F> 20 is true. Will be displayed. Since false || The result is true true e <10 || f> 20 results true. And the browser Result of E <10 || F> 20 is True. Is displayed.

Comments

comments

About the author

Toriqul Islam Tusher

বলার মত কিছু নাই!

Leave a Comment