java script logical operators code example
Example 1: or operator in 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
}
Example 2: js ===
5 =='5' // true: ignores type
5 === '5' // false: includes type
Example 3: js !==
var x = 5;
// === equal value and equal type
// e.g. 1.
x === 5 returns true
// e.g. 2.
x === "5" returns false
// !== not equal value or not equal type
// e.g. 1.
x !== 5 returns false
// e.g. 2.
x !== "5" returns true
// e.g. 3.
x !== 8 returns true