JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods
Arrays

JAVASCRIPT BOOLEAN OPERATORS

Javascript boolean operators, also known as logical operators allow you to evaluate multiple expressions at a time. Returns either true or false.

These three boolean operators are &&, || and ! and are explained below with examples:

And Operator: &&

Check if both are conditions are satisfied.

Example:

if(firstName=='John' && lastName=='Smith')
{
alert('Welcome');
}

By using && between two conditions, we are saying that only if these two conditions are true, must the code between the braces execute.

Or Operator: ||

Check if either are conditions are satisfied.

Example:

if(firstName=='John' || lastName=='Smith')
{
alert('Welcome');
}

By using || between two conditions, we are saying that if either of these two conditions are true, must the code between the braces execute.

Not Operator: !

Check if conditions are not the case.

Example:

if(!(firstName=='John'))
{
alert('Welcome');
}

We are saying that if firstName is not John, the conditions evaluates to true, then the code between the braces must execute.

Home | Privacy Policy | Terms Of Use | Contact Us