Logical Operators: The Logical AND (&&) and the Logical OR (||)



Navigation Aids -- This Page        Navigation Aids -- This Topic        Navigation Aids -- This Site




Review of Terms Related to This Topic





The Purpose for this Page

This page will show the basic rules for JavaScript logical operator group. Some special situation cases are explained. And finally, some scripting examples are provided with comments.





The Basics of Logical Operators





Special Situations





Some Script Examples


Expression Giving x= Comment
var x = true, y = true;
alert(x && y);
true Logical AND Operation
both operands evaluate to be true giving a true result
var x = true, y = true;
alert(x || y);
true Logical OR Operation
either operand may evaluate to be true giving a true result
var x = false, y = true;
alert(x && y);
false Logical AND Operation
both operands must evaluate to be true to give a true result
var x = false, y = true;
alert(x || y);
true Logical OR Operation
one operand evaluates to be true giving a true result
var x = false, y = false;
alert(x && y);
false Logical AND Operation
both operands evaluate to be false to give a false result
var x = false, y = false;
alert(x || y);
false Logical OR Operation
neither operand evaluates to be true giving a false result


Top            

Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson