[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match [Back]  [Original]

Symbol.match - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Symbol.match

Baseline

20201

Symbol.match Symbol.match String.prototype.match() 1

RegExp.prototype[Symbol.match]() String.prototype.match()

const regexp = /foo/;
// console.log('/foo/'.startsWith(regexp));
//  (Chrome): Error: First argument to String.prototype.startsWith must not be a regular expression
//  (Firefox): Error: Invalid type: first can't be a Regular Expression
//  (Safari): Error: Argument to String.prototype.startsWith cannot be a RegExp

regexp[Symbol.match] = false;

console.log("/foo/".startsWith(regexp));
// : true

console.log("/baz/".endsWith(regexp1));
// : false

Symbol.match

Symbol.match

String.prototype.startsWith(), String.prototype.endsWith(), String.prototype.includes() TypeError match false undefined

isRegExp

TypeError

js
"/bar/".startsWith(/bar/);

// TypeError /bar/ 
// Symbol.match 

Symbol.match false startsWith endsWith TypeError

js
const re = /foo/;
re[Symbol.match] = false;
"/foo/".startsWith(re); // true
"/baz/".endsWith(re); // false

ECMAScript 2027 LanguageSpecification
# sec-symbol.match


Web Proxy Viewer  |  New URL  |  Original Page