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

I’ve been working with JavaScript for quite a while, and for modern codebases, this is my go-to method.

You can easily use .includes() for this! It’s super clean and works like a charm:

if (categories.includes("specialword")) {
  console.log("Found it!");
}

This method is supported in all modern browsers and keeps your code neat. For most javascript find string in array needs, this is the first thing I reach for.