Categories
TypeScript Answers

How to check whether an array contains a string in TypeScript?

Spread the love

To check whether an array contains a string in TypeScript, we call the includes method.

For instance, we write

console.log(channelArray.includes("three"));

to check if the channelArray has 'three' in it with 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.