How to find the index of an item in array in JavaScript

1 Answer

0 votes
const arr = ["javascript", "php", "c++", "python"];
 
const pos = arr.indexOf('php');

console.log(pos);



/*
run:

1

*/

 



answered May 17, 2016 by avibootz
edited Feb 1, 2025 by avibootz

Related questions

1 answer 220 views
3 answers 286 views
1 answer 186 views
1 answer 206 views
2 answers 275 views
...