Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get all indexes for element in array javascript

function getAllIndexes(arr, val) {
    var indexes = [], i;
    for(i = 0; i < arr.length; i++)
        if (arr[i] === val)
            indexes.push(i);
    return indexes;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #indexes #element #array #javascript
ADD COMMENT
Topic
Name
6+4 =