Categories
JavaScript Answers

How to find if an array contains a specific string in JavaScript?

Spread the love

To find if an array contains a specific string in JavaScript, we use the includes method.

For instance, we write

const found = categories.includes("foo");

to check of 'foo' is in the categories array with categories.includes.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.