How to get the index of an element in array by value with TypeScript

1 Answer

0 votes
let arr: Array<string> = ['TypeScript', 'C', 'C++', 'Java', 'Python']; 

console.log(arr.indexOf('C++'));
 
 
 
/*
 
run:
 
2

*/

 



answered Oct 23, 2021 by avibootz
...