JavaScript Symbol.match Property - JavaScript Tutorial

JavaScript Symbol.match Property

BLUF: This tutorial on JavaScript Symbol.match Property provides an in-depth look at JavaScript's core features. It includes practical examples and code snippets to help you master modern JS development.
Key Discovery: JavaScript Symbol.match Property

Understanding JavaScript Symbol.match Property is crucial for building dynamic, interactive web applications. Explore the examples below to see it in action.

The JavaScript Symbol.match serves the purpose of determining whether a regular expression corresponds with a given string.

Syntax

Example

Symbol.match

Parameters

String

Return value

Return true if a string matches otherwise false.

Browser Support

Chrome 32
Safari 8
Firefox 29
Opera 19

Example 1

Example

<script>

//JavaScript to illustrate Symbol.match

var reg = /example/;

reg[Symbol.match] = false;

// check string start with hello

document.write('/example/'.startsWith(reg));

// check string ends with hi

document.write("<br>");

document.write('/we/'.endsWith(reg));

//expected output: true

// false

</script>

Output:

Output

True

False

Example 2

Example

<script>

//JavaScript to illustrate Symbol.match

var reg = /Java123/;

reg[Symbol.match] = false;

// check string start with qw

document.write('/qw/'.startsWith(reg));

// check string ends with 34

document.write("<br>");

document.write('/34/'.endsWith(reg));

//expected output: false

// false

</script>

Output:

Output

false

false

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience