Last active
January 28, 2019 20:09
-
-
Save ericcornelissen/04c62c573814ba9cdec1d6158d2ad676 to your computer and use it in GitHub Desktop.
Small function to check equality across any number of variables.
This file contains hidden or 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
| /** | |
| * Check equality across any number of variables. | |
| * | |
| * @example <caption>Simple usage</caption> | |
| * var a = 1, b = 1, c = 1, d = 2; | |
| * eql(a, b, c); // returns True | |
| * eql(a, b, c, d); // returns False | |
| * | |
| * @example <caption>Wierd use cases</caption> | |
| * eql("foobar"); // returns True | |
| * eql(); // returns True | |
| * | |
| * @param {...*} arg The arguments to compare. | |
| * @return {boolean} True if all arguments are equal, false otherwise. | |
| * @license The-Unlicense | |
| */ | |
| function eql() { | |
| var base = arguments[0]; | |
| for (var i = 1; i < arguments.length; i++) { | |
| if (base !== arguments[i]) return false; | |
| } | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment