A RetroSearch Logo

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

Search Query:

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

Symbol.split - JavaScript | MDN

Symbol.split

Baseline Widely available

Die statische Dateneigenschaft Symbol.split repräsentiert das bekannte Symbol Symbol.split. Die Methode String.prototype.split() sucht dieses Symbol im ersten Argument für die Methode, die einen String an den Indizes aufteilt, die mit dem aktuellen Objekt übereinstimmen.

Für mehr Informationen siehe RegExp.prototype[Symbol.split]() und String.prototype.split().

Probieren Sie es aus
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"
Wert

Das bekannte Symbol Symbol.split.

Schreibbar nein Aufzählbar nein Konfigurierbar nein Beispiele Benutzerdefiniertes Rückwärts-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" ]
Spezifikationen Browser-Kompatibilität Siehe auch MDN-Feedback-Box War diese Übersetzung hilfreich?

Diese Seite wurde automatisch aus dem Englischen übersetzt.


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