Last active
February 25, 2022 18:54
-
-
Save Alynva/d36568d3b4839584a520ee1babec663b to your computer and use it in GitHub Desktop.
Operators && and || rewritten without using the operator itself
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const and = (...args) => args.every(x => x) | |
const and = (a, b) => !!(!!(a || b) ^ !!a ^ !!b) | |
const and = (...args) => args.reduce((a, b) => !!(!!(a || b) ^ !!a ^ !!b), true) | |
const and = (...args) => args.length ? args.shift() ? and(...args) : false : true | |
const or = (...args) => args.some(x => x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment