Answers for "how to get the index of the array"

1

get index of item array

const array = ['a', 'b', 'c']
array.indexOf('a')
 > 0
Posted by: Guest on November-02-2021
5

get index of element in array js

const beasts = ['ant', 'bison', 'camel', 'duck', 'bison'];

beasts.indexOf('bison'); //ouput: 1

// start from index 2
beasts.indexOf('bison', 2); //output: 4

beasts.indexOf('giraffe'); //output: -1
Posted by: Guest on October-28-2020

Code answers related to "how to get the index of the array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language