0 votes
in JavaScript by
What is the purpose of exec method in javascript?

1 Answer

0 votes
by

The purpose of exec method is similar to test method but it executes a search for a match in a specified string and returns a result array, or null instead of returning true/false.

var pattern = /you/;
console.log(pattern.exec("How are you?")); //["you", index: 8, input: "How are you?", groups: undefined]

Related questions

0 votes
asked Sep 26, 2023 in JavaScript by AdilsonLima
0 votes
asked Oct 24, 2023 in JavaScript by DavidAnderson
...