Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

search an array with regex javascript indexOf

const array = ["page=4", "sortOrder=asc", "datePosted=all-time", "sortOrder=desc"];
const index = array.findIndex(value => /^sortOrder=/.test(value));
// index = 1;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #search #array #regex #javascript #indexOf
ADD COMMENT
Topic
Name
3+4 =