Use the includes() method on the array instance.

For example:

['red', 'green'].includes('red') //true ✅

['red', 'green'].includes('yellow') //false ❌

Download my free JavaScript Beginner's Handbook, and check out my premium React/Vue/Svelte/Node/Next.js courses!


Coming soon:
Click to find out more ⤴️