Check if a thing is in an array
npm install isin
Check out the tests if this is unclear to you:
var isin = require("isin").isin;
var notin = require("isin").notin;
var options = [1,2,3,4,5];
if( isin( options, 9 ) ){
console.log("We have a 9!");
}
if( notin(options, 10) ){
console.log("We can do without a 10!");
}
I got sick and tired of if( Array.isArray(options) && options.indexOf(foo) !== -1 )
Plus, there are 42
tests.
better be verbose then sorry