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/TypedArray/fill below:

TypedArray.prototype.fill() - JavaScript | MDN

TypedArray.prototype.fill()

Baseline Widely available

Die fill()-Methode von TypedArray-Instanzen ändert alle Elemente innerhalb eines Indexbereichs in einem typisierten Array in einen statischen Wert. Sie gibt das modifizierte typisierte Array zurück. Diese Methode hat denselben Algorithmus wie Array.prototype.fill().

Probieren Sie es aus
const uint8 = new Uint8Array([0, 0, 0, 0]);
// Value, start position, end position
uint8.fill(4, 1, 3);

console.log(uint8);
// Expected output: Uint8Array [0, 4, 4, 0]
Syntax
fill(value)
fill(value, start)
fill(value, start, end)
Parameter
value

Wert, mit dem das typisierte Array gefüllt werden soll.

start Optional

Nullbasierter Index, ab dem gefüllt werden soll, in eine Ganzzahl umgewandelt.

end Optional

Nullbasierter Index, bis zu dem gefüllt werden soll, in eine Ganzzahl umgewandelt. fill() füllt bis, aber nicht einschließlich end.

Rückgabewert

Das modifizierte typisierte Array, gefüllt mit value.

Beschreibung

Siehe Array.prototype.fill() für weitere Details. Diese Methode ist nicht generisch und kann nur auf Instanzen von typisierten Arrays aufgerufen werden.

Beispiele Nutzung von fill()
new Uint8Array([1, 2, 3]).fill(4); // Uint8Array [4, 4, 4]
new Uint8Array([1, 2, 3]).fill(4, 1); // Uint8Array [1, 4, 4]
new Uint8Array([1, 2, 3]).fill(4, 1, 2); // Uint8Array [1, 4, 3]
new Uint8Array([1, 2, 3]).fill(4, 1, 1); // Uint8Array [1, 2, 3]
new Uint8Array([1, 2, 3]).fill(4, -3, -2); // Uint8Array [4, 2, 3]
Spezifikationen Browser-Kompatibilität Siehe auch

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