What is difference between test() and exec() in JavaScript?
test(): is used to find a string for a specific pattern. It will return the Boolean value 'true' on finding the given text otherwise, it will return 'false'.
exec(): is used to search a string for a specific pattern, and if it finds it, it'll return the pattern directly; else, it'll return an 'empty' result.