Modern browsers have Array#includes, which does exactly that and is widely supported by everyone except IE:

console.log(['joe', 'jane', 'mary'].includes('jane')); //true

You can also use Array#indexOf, which is less direct, but doesn't require polyfills for outdated browsers.


Many frameworks also offer similar methods:

Notice that some frameworks implement this as a function, while others add the function to the array prototype.