Skip to content

Instantly share code, notes, and snippets.

@mkuklis
Created June 7, 2011 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkuklis/1012380 to your computer and use it in GitHub Desktop.
Save mkuklis/1012380 to your computer and use it in GitHub Desktop.
eq to any in JavaScript
function eqToAny (el /*, args */) {
var args = [].slice.call(arguments, 1);
if (args.length == 0) return false;
for (var i = 0, l = args.length; i < l; i++) {
if (el === args[i]) {
return true;
}
}
return false;
}
var a = 1;
var b = 2;
var c = 3;
var d = 1;
console.log(eqToAny(a, b, c, d)); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment