# logical operators javascript

``````//The OR operator in Javascript is 2 verticals lines: ||

var a = true;
var b = false;

if(a || b) {
//one of them is true, code inside this block will be executed
}Javascript Comparison Operators
== Equal to
=== Equal value and equal type
!= Not equal
!== Not equal value or not equal type
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
? Ternary operator
Javascript Logical Operators
&& Logical and
|| Logical or
! Logical not
var hungry=true;
var slow=true;
var anxious=true;

//&& means and
if(hungry && slow && anxious){
var cause="weed";
}Operator	Example	Same As
=	x = y	x = y
+=	x += y	x = x + y
-=	x -= y	x = x - y
*=	x *= y	x = x * y
/=	x /= y	x = x / y
%=	x %= y	x = x % y
**=	x **= y	x = x ** y// There are 3 Javascript Logical Operators
// || (OR)
// && (AND)
// ! (NOT)

if (a || b) {
console.log("I will run if either a or b are true");
}

if (a && b) {
console.log("I will run, if and only if a and b are both true");
}

if (!a) {
console.log("I will only run if a is false");
}

if (a) {
console.log("I will only run if a is true");
}
``````
Source