Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #index #element #array #js
ADD COMMENT
Topic
Name
7+5 =