1Javascript Comparison Operators
2== Equal to
3=== Equal value and equal type
4!= Not equal
5!== Not equal value or not equal type
6> Greater than
7< Less than
8>= Greater than or equal to
9<= Less than or equal to
10? Ternary operator
11
1//The OR operator in Javascript is 2 verticals lines: ||
2
3var a = true;
4var b = false;
5
6if(a || b) {
7 //one of them is true, code inside this block will be executed
8}
1var a = 2;
2var b = 5;
3var c = 10;
4
5if (a === 3 || a === 2) {
6 console.log("TRUE");
7} else {console.log("FALSE");}
8if (a === 4 || b === 3 || c === 11) {
9 console.log("TRUE");
10} else {console.log("FALSE");}
11if (b === 5 || c != 10) {
12 console.log("TRUE");
13} else {console.log("FALSE");}
14
15/* Output:
16TRUE
17FALSE
18TRUE
19*/
1//|| is the or operator in JavaScript
2if(a == 1 || b != 'value'){
3 yourFunction();
4}
1let a = 1;
2let b = -1;
3
4if (a > 0 & b > 0){
5 console.log("and");
6} else if (a > 0 || b > 0){
7 console.log("or");
8}