![]() |
VOOZH | about |
JavaScript Symbol match property is used to identify the matching of a regular expression against a string and this function is called using String match() method.
Syntax:
regexp[Symbol.match] = false;
Parameters: It does not accept any parameters.
Return value: It will return the Boolean value for a string matching if matches found then it will return true otherwise returns false. Below examples illustrate the Symbol.match property in JavaScript.
Below examples illustrate the JavaScript Symbol match Property:
Example 1: In this example, we will check if a string starts with a particular expression defined in regexp
Output:
false true
Example 2: In this example, we will pass a regular expression and see the type of error returned.
Output:
Error: First argument to String.prototype.startsWith must not be a regular expression.
Supported Browsers: The browsers supported by Symbol.match property are listed below:
We have a complete list of Javascript symbols' properties and methods, to check those please go through the Javascript Symbol Complete Reference article.