The same as in JavaScript, using Array.prototype.indexOf():
console.log(channelArray.indexOf('three') > -1);
Or using ECMAScript 2016 Array.prototype.includes():
console.log(channelArray.includes('three'));
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
const arr = [{foo: 'bar'}, {foo: 'bar'}, {foo: 'baz'}]; console.log(arr.find(e => e.foo === 'bar')); // {foo: 'bar'} (first match) console.log(arr.some(e => e.foo === 'bar')); // true console.log(arr.filter(e => e.foo === 'bar')); // [{foo: 'bar'}, {foo: 'bar'}]
Reference
Related Posts:
- What’s the difference between “{}” and “[]” while declaring a JavaScript array?
- For-each over an array in JavaScript
- What is TypeScript and why would I use it in place of JavaScript? [closed]
- ES6 Map in Typescript
- How do I check if an array includes a value in JavaScript?
- Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’
- How can I remove a specific item from an array?
- Find object by id in an array of JavaScript objects
- How can I access and process nested objects, arrays or JSON?
- How to define type for a function callback (as any function type, not universal any) used in a method parameter
- Split string into array
- How can I remove a specific item from an array?
- Sort array of objects by string property value
- TypeScript foreach return [duplicate]
- Copy array by value
- How can I reverse an array in JavaScript without using libraries?
- What is the way of declaring an array in JavaScript?
- How to create an associative array in JavaScript literal notation
- TypeScript React.FC
confusion - Remove duplicate values from JS array [duplicate]
- How can I create a two dimensional array in JavaScript?
- How to loop through an array containing objects and access their properties
- How do I empty an array in JavaScript?
- Remove duplicate values from JS array
- How can I create a two dimensional array in JavaScript?
- How to loop through an array containing objects and access their properties
- How to filter an array/object by checking multiple values
- How do you check if a variable is an array in JavaScript?
- How do I empty an array in JavaScript?
- How to find the sum of an array of numbers
- How to perform string interpolation in TypeScript?
- Angular: mat-form-field must contain a MatFormFieldControl
- Remove Object from Array using JavaScript
- Short circuit Array.forEach like calling break
- Typescript : Property does not exist on type ‘object’
- Remove duplicate values from JS array
- How to check if array is empty or does not exist?
- Why is using “for…in” for array iteration a bad idea?
- Deleting array elements in JavaScript – delete vs splice
- Filter array to have unique values
- How to randomize (shuffle) a JavaScript array?
- Better way to sum a property value in an array
- Angular ForEach in Angular4/Typescript?
- How to convert an Object {} to an Array [] of key-value pairs in JavaScript
- Fastest way to duplicate an array in JavaScript – slice vs. ‘for’ loop
- How to print elements from array with javascript
- Remove Object from Array using JavaScript
- Angular4 – No value accessor for form control
- What is the difference between ( for… in ) and ( for… of ) statements?
- What’s the difference between “Array()” and “[]” while declaring a JavaScript array?
- Short circuit Array.forEach like calling break
- Short circuit Array.forEach like calling break
- How to remove item from array by value?
- Possible to extend types in Typescript?
- RegExp in TypeScript
- How do you format a Date/Time in TypeScript?
- How to loop through an array containing objects and access their properties
- Sorting arrays in javascript by object key value
- npm WARN … requires a peer of … but none is installed. You must install peer dependencies yourself
- Convert Array to Object
- What is ViewChild in Angular2?
- How do you put an image file in a json object?
- push object into array
- Counting the occurrences / frequency of array elements
- Remove last item from array
- Get all non-unique values (i.e.: duplicate/more than one occurrence) in an array
- Uncaught ReferenceError: define is not defined typescript
- How to add an object to an array
- Finding the average of an array using JS
- String.Format not work in TypeScript
- How to change value of object which is inside an array using JavaScript or jQuery?
- Checking for duplicate strings in JavaScript array
- TypeError: Class extends value undefined is not a function or null
- use Lodash to sort array of object by value
- Can’t perform a React state update on an unmounted component
- Showing an image from an array of images – Javascript
- Is there a simple way to make a random selection from an array in JavaScript or any other programming language?
- Uncaught TypeError: Cannot read property ‘toUpperCase’ of undefined
- How to get the difference between two arrays in JavaScript?
- Sort array of objects by single key with date value
- Most efficient method to groupby on an array of objects
- Array Mapping in AngularJs
- Angular 4 setTimeout() with variable delay and wait
- Return array from function
- Javascript call() & apply() vs bind()?
- How to get the first element of an array?
- JavaScript array to CSV
- How to sort an array of integers correctly
- console.log showing contents of array object
- How to sort 2 dimensional array by column value?
- Get JavaScript object from array of objects by value of property [duplicate]
- Complex JSON nesting of objects and arrays
- How do I store an array in localStorage?
- How to determine if Javascript array contains an object with an attribute that equals a given value?
- JavaScript Array Push key value
- How to initialize an array’s length in JavaScript?
- typescript – cloning object
- Angular 2 Sort table columns
- Find a value in an array of objects in Javascript [duplicate]
- How do I install Angular 2 using NPM?