logical operator javascript code example

Example 1: js greater than or equal to

>= // greater than or equal 
<= // less than or equal
> // greater than
< // less than
== // equals
=== // strictly equals
!= // not equals
!== // stricly not equals

Example 2: js logical operators

Javascript Logical Operators
&& Logical and
|| Logical or
! Logical not

Example 3: javascript and

var hungry=true;
var slow=true;
var anxious=true;

//&& means and
if(hungry && slow && anxious){ 
	var cause="weed";
}

Example 4: or operator javascript

//|| is the or operator in JavaScript
if(a == 1 || b != 'value'){
    yourFunction();
}

Example 5: or statment javscript

if (x === 5 || x === 8)
  console.log("x is eaqual to 5 OR 8")

Example 6: or operator javascript

var a = 2;
var b = 5;
var c = 10;

if (a === 3 || a === 2) {
	console.log("TRUE");
} else {console.log("FALSE");}
if (a === 4 || b === 3 || c === 11) {
	console.log("TRUE");
} else {console.log("FALSE");}
if (b === 5 || c != 10) {
	console.log("TRUE");
} else {console.log("FALSE");}

/* Output:
TRUE
FALSE
TRUE
*/

Tags:

Php Example