You could use this...
if (["something", "nothing", "anything", "everything"].includes(a)) {
alert('Who cares?');
}
If you're stuck with older browser support...
if (["something", "nothing", "anything", "everything"].indexOf(a) > -1) {
alert('Who cares?');
}
You also tagged it jQuery, so if you need to support older browsers without Array.prototype.indexOf()
, you could use $.inArray()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…