Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js array find regex

const array = ["page=4", "sortOrder=asc", "datePosted=all-time", "sortOrder=desc"];
const match = array.find(value => /^sortOrder=/.test(value));
// match = "sortOrder=asc"
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #array #find #regex
ADD COMMENT
Topic
Name
8+7 =