How do I check whether an array contains a string in TypeScript?
The same as in JavaScript, using Array.prototype.indexOf(): Or using ECMAScript 2016 Array.prototype.includes(): Note that you could also use methods like showed by @Nitzan to find a string. However you wouldn’t usually do that for a string array, but rather for an array of objects. There those methods were more sensible. For example Reference Array.find() Array.some() Array.filter()