Baseline Widely available
Symbol.split
ì ì ë°ì´í° ìì±ì ì ìë ¤ì§ ì¬ë³¼ @@split
ì ëíë
ëë¤. String.prototype.split()
ë©ìëë íì¬ ê°ì²´ì ì¼ì¹íë ì¸ë±ì¤ìì 문ìì´ì ë¶í íë ë©ìëì 첫 ë²ì§¸ ì¸ììì ì´ ì¬ë³¼ì ì°¾ìµëë¤.
ë³´ë¤ ìì¸í ë´ì©ì RegExp.prototype[@@split]()
ë° String.prototype.split()
를 참조íì기 ë°ëëë¤.
class Split1 {
constructor(value) {
this.value = value;
}
[Symbol.split](string) {
const index = string.indexOf(this.value);
return `${this.value}${string.substring(0, index)}/${string.substring(
index + this.value.length,
)}`;
}
}
console.log("foobar".split(new Split1("foo")));
// Expected output: "foo/bar"
ê°
ì ìë ¤ì§ ì¬ë³¼ @@split
.
class ReverseSplit {
[Symbol.split](string) {
const array = string.split(" ");
return array.reverse();
}
}
console.log("Another one bites the dust".split(new ReverseSplit()));
// [ "dust", "the", "bites", "one", "Another" ]
ëª
ì¸ì ë¸ë¼ì°ì í¸íì± ê°ì´ 보기
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