Symbol.split - JavaScript | MDN
Интерактивный пример
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"
Атрибуты свойства Symbol.split | |
|---|---|
| Записываемое | нет |
| Перечисляемое | нет |
| Настраиваемое | нет |
Спецификации
| Specification |
|---|
| ECMAScript® 2026 Language Specification # sec-symbol.split |