Skip to main content

//Logical Operator

Logical Operator


  1.  <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. </head>
  7. <body>
  8. <script type="text/javascript">

  9. var a = 50;
  10. var b = 30;

  11. //Logical AND
  12.        //we use also  Logical NOT
  13. if (!((a > b) && (a == b))) // !(a=50 > b=30) is False && (a=50 != b=30) is True; Therefore this statement is False.
  14.                                    // when both statement are True then result will be True.
  15.                                   // '!'not is True statement consider False and False statement consider to True.
  16. {
  17. document.write("this statement is true <br>");
  18. } else {
  19. document.write("this statement is false <br>"); // document.write() use for print line.
  20. }

  21. //Logical OR
  22. if ((a == b) || (a != b)) {  // (a=50 < b=30) is False || (a=50 != b=30) is True; therefore this statement is True.
  23.                                     //if one(or both) statement is True then result will be True, Otherwise it returns False.
  24. document.write("this statement is true <br>");
  25. } else {
  26. document.write("this statement is false <br>"); //"<br>" use for linebreak.
  27. }
  28. </script>
  29. </body>
  30. </html>



//Execute


//Output

/*

//Logical AND

this statement is true


//Logical OR

this statement is true

*/



                                                    //ThE ProFessoR