How to get the index of an object in an array in TypeScript

1 Answer

0 votes
const arr = [{lang: 'javascript'}, {lang: 'typescript'}, {lang: 'nodejs'}, {lang: 'c++'}];
  
const index = arr.findIndex(object => {
  	return object.lang === 'typescript';
});
  
console.log(index);
  
    
    
    
/*
run:
    
1
    
*/

 



answered Jul 8, 2022 by avibootz

Related questions

...