Baseline Widely available
Symbol.match
ì ì ë°ì´í° ìì±ì ì ìë ¤ì§ ì¬ë³¼ @@match
를 ëíë
ëë¤. String.prototype.match()
ë©ìëë ì
ë ¥ 문ìì´ì íì¬ ê°ì²´ì ì¼ì¹ìí¤ë ë° ì¬ì©ëë ë©ìëì 첫 ë²ì§¸ ì¸ììì ì´ ì¬ë³¼ì ì¡°íí©ëë¤. ì´ ì¬ë³¼ì ê°ì²´ë¥¼ ì ê· ííìì¼ë¡ ì²ë¦¬í´ì¼ íëì§ ì¬ë¶ë¥¼ ê²°ì íë ë°ë ì¬ì©ë©ëë¤.
ì¢ ë ë§ì ì 보를 ìê³ ì¶ì¼ìë©´ RegExp.prototype[@@match]()
ì String.prototype.match()
를 ì°¸ê³ íì기 ë°ëëë¤.
const regexp1 = /foo/;
// console.log('/foo/'.startsWith(regexp1));
// Expected output (Chrome): Error: First argument to String.prototype.startsWith must not be a regular expression
// Expected output (Firefox): Error: Invalid type: first can't be a Regular Expression
// Expected output (Safari): Error: Argument to String.prototype.startsWith cannot be a RegExp
regexp1[Symbol.match] = false;
console.log("/foo/".startsWith(regexp1));
// Expected output: true
console.log("/baz/".endsWith(regexp1));
// Expected output: false
ê°
ì ìë ¤ì§ ì¬ë³¼ @@match
.
ì´ í¨ìë ê°ì²´ì ì ê· ííìì ëìì´ ìëì§ë¥¼ ìë³íë ë°ìë ì¬ì©ë©ëë¤. String.prototype.startsWith()
, String.prototype.endsWith()
ê·¸ë¦¬ê³ String.prototype.includes()
를 ìë¡ ë¤ìë©´ 첫 ì¸ìê° ì ê·ìì¸ì§ íì¸íê³ ì ê·ìì¸ ê²½ì° TypeError
를 ë°ììíµëë¤. ì´ì match
ì¬ë³¼ì´ false
(ëë undefined
ì ì ì¸í ê±°ì§ ê°ì ê°)ë¡ ì¤ì ëì´ ìì¼ë©´ í´ë¹ ê°ì²´ë¥¼ ì ê·ì ê°ì²´ë¡ ì¬ì©í ì ììì ëíë
ëë¤.
ë¤ì ì½ëë TypeError
를 ë°ììíµëë¤.
"/bar/".startsWith(/bar/);
// /bar/ê° ì ê· ííìì´ê¸°ì TypeError ë°ì
// ê·¸ë¦¬ê³ Symbol.match ë ìì ëì§ ìììµëë¤.
ê·¸ë¬ë Symbol.match
를 false
ë¡ ì¤ì íë©´ ê°ì²´ë ì ê·ì ê°ì²´ê° ìëì¼ë¡ ê°ì£¼ë©ëë¤. startsWith
ì endsWith
ë©ìëë ê²°ê³¼ì ì¼ë¡ TypeError
를 ë°ììí¤ì§ ììµëë¤.
const re = /foo/;
re[Symbol.match] = false;
"/foo/".startsWith(re); // true
"/baz/".endsWith(re); // false
ëª
ì¸ì ë¸ë¼ì°ì í¸íì± ê°ì´ 보기
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4