| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match | [Back] [Original] |
Get to know MDN better
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 "/bar/".startsWith(/bar/);
// TypeError /bar/
// Symbol.match
Symbol.match false startsWith endsWith TypeError
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 |