Skip to content

Instantly share code, notes, and snippets.

@letsgetrandy
Created June 23, 2014 20:18
Show Gist options
  • Save letsgetrandy/52d7d0da1f14dc4cbe8a to your computer and use it in GitHub Desktop.
Save letsgetrandy/52d7d0da1f14dc4cbe8a to your computer and use it in GitHub Desktop.
A few semantic functions for Javascript...
/**
* Returns TRUE if all arguments passed in can be evaluated as true.
* Otherwise, returns FALSE.
*/
function all() {
var i, l = arguments.length;
for (i = 0; i < l; i++) {
if (!arguments[i]) {
return false;
}
}
return true;
}
/**
* Returns TRUE if any argument passed in can be evaluated as true.
* Otherwise, returns FALSE.
*/
function any() {
var i, l = arguments.length;
for (i = 0; i < l; i++) {
if (arguments[i]) {
return true;
}
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment