includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate.
Modern browsers have Array#includes, which does exactly that and is widely supported by everyone except IE:
var array = [50, 100, 200]; console.log(array.includes(50)); // expected output: true console.log(array.includes(10)); // expected output: false
You can also use Array#indexOf, which is less direct, but doesn’t require polyfills for outdated browsers.
var array = [50, 100, 200]; console.log(array.indexOf(50) >= 0); // expected output: true console.log(array.indexOf(10) >= 0); // expected output: false