If you just want to know if matching occurs between the RegExp pattern and the available string, then you have to use the test() method of the RegExp object. The following code illustrates this:
var availableString = "The dog is outside the house.";
var re = /dog/
The available string is "The dog is outside the house." The RegExp pattern is /dog/. The RegExp object is the re variable. The test() method takes the available string as an argument. So in the if-condition we have,
Is there an equivalent String method? No. There is no equivalent string method that will simply return true or false. Whenever you just need to know whether a match occurs (true) or not (false), use the test() method of the regular expression object (RexExp).