A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/es/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split below:

Symbol.split - JavaScript | MDN

Symbol.split

Baseline Widely available

El símbolo conocido como Symbol.split especifica el método que divide una cadena en los índices que coinciden con una expresión regular. Esta función es llamada por el método String.prototype.split().

Para más información, véase RegExp.prototype[@@split]() y String.prototype.split().

Pruébalo
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"
Sobrescribir No Numerable No Configurable No Ejemplos División inversa personalizada
class ReverseSplit {
  [Symbol.split](string) {
    const array = string.split(" ");
    return array.reverse();
  }
}

console.log("Another one bites the dust".split(new ReverseSplit()));
// resultado esperado: [ "dust", "the", "bites", "one", "Another" ]
Especificaciones Compatibilidad con navegadores Véase también

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