![]() |
VOOZH | about |
Lodash _.isRegExp() method is used to find whether the given value is a regular expression or not. It returns True if the given value is a regular expression. Otherwise, it returns false.
_.isRegExp(value);Example 1: In this example, we are passing a regular expression to the lodash _.isRegExp() method. the object starts and ends with ‘/’, therefore it is a regular expression. Hence, the result is true.
Output:
trueExample 2: In this example, we are passing a string to the _.isRegExp() function Since a string is not a regular expression, the output will be false.
Output:
falseNote: This code will not work in normal JavaScript because it requires the library lodash to be installed.