>=
)console.log(5 >= 3); // true console.log(3 >= 3); // true // Compare bigint to number does not work console.log(3n >= 5); // false console.log("ab" >= "aa"); // true "a" >= "b"; // false "a" >= "a"; // true
<=
)console.log(5 <= 3); // false console.log(3 <= 3); // true // Compare bigint to number does not work console.log(3n <= 5); // true console.log("aa" <= "ab"); // true "a" <= "b"; // true "a" <= "a"; // true
Comparison logic for up to three elements is straightforward. Comparing more elements need more clever solutions.
/* manual comparison of 3 elements */ if(g === h && g === f) { "do something" } /* looping comparison of n-elements */ function nEqual(){ for (let i = 1; i < arguments.length; i++){ if ( arguments[i] === null || arguments[i] !== arguments[i-1] ) { return false; } return true; }; nEqual(a,b,c,d,e,f,g,h) && { "do something" }