logical operators js code example
Example 1: javascript and operator
const x = 7;
const y = 4;
(x == 7 && y == 5);
(x == 3 && y == 4);
(x == 7 && y == 4);
if (condition == value && condition == otherValue) {
return something;
}
Example 2: js logical operators
Javascript Logical Operators
&& Logical and
|| Logical or
! Logical not
Example 3: or operator javascript
if(a == 1 || b != 'value'){
yourFunction();
}
Example 4: and operator in javascript
var a = true
var b = ""
var c = 1
true && ""
"" && 1
false && 5
Example 5: js comparison operators
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
Example 6: and operator in javascript
console.log(5 & 13);