Symbol.match JavaScript JS

The JavaScript Symbol.match property looks for the matching of a regular expression against a string.

Syntax:

Symbol.match

Parameters:
string: It represents the string.

Returns:
It returns true if a regular expression matches against a string, otherwise, it returns true.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script>
var alpha = /HELLO WORLD/;
alpha[Symbol.match] = false;
document.write('/HELLO WORLD/'.startsWith(alpha));
</script>
</body>
</html>

Example 2:

<!DOCTYPE html>
<html>
<body>
<script>
const regExp = /w3schools/;
regExp[Symbol.match] = false;
document.write('/w3schools/'.startsWith(regExp));
document.write("</br>");
document.write('/jai/'.endsWith(regExp));
</script>
</body>
</html>