javascript all logical operators code example

Example 1: js logical operators

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

Example 2: javascript

||// || means or

Example 3: || in js

const a = 3;
const b = -2;

console.log(a > 0 || b > 0);
// expected output: true

Example 4: logical operators javascript

// 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");
}

Tags:

Php Example