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/replace below:

Symbol.replace - JavaScript | MDN

Symbol.replace

Baseline Widely available

Die statische Dateneigenschaft Symbol.replace repräsentiert das wohlbekannte Symbol Symbol.replace. Die Methoden String.prototype.replace() und String.prototype.replaceAll() suchen dieses Symbol in ihrem ersten Argument, um die Methode zu finden, die Teilstrings ersetzt, die mit dem aktuellen Objekt übereinstimmen.

Für weitere Informationen siehe RegExp.prototype[Symbol.replace](), String.prototype.replace(), und String.prototype.replaceAll().

Probieren Sie es aus
class Replace1 {
  constructor(value) {
    this.value = value;
  }
  [Symbol.replace](string) {
    return `s/${string}/${this.value}/g`;
  }
}

console.log("foo".replace(new Replace1("bar")));
// Expected output: "s/foo/bar/g"
Wert

Das wohlbekannte Symbol Symbol.replace.

Schreibbar nein Aufzählbar nein Konfigurierbar nein Beispiele Verwendung von Symbol.replace
class CustomReplacer {
  constructor(value) {
    this.value = value;
  }
  [Symbol.replace](string) {
    return string.replace(this.value, "#!@?");
  }
}

console.log("football".replace(new CustomReplacer("foo"))); // "#!@?tball"
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