A RetroSearch Logo

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

Search Query:

Showing content from https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/keys below:

TypedArray.prototype.keys() - JavaScript | MDN

TypedArray.prototype.keys()

Baseline Widely available

La méthode keys() renvoie un nouvel objet Array Iterator contenant les clés pour chaque indice du tableau typé.

Exemple interactif
const uint8 = new Uint8Array([10, 20, 30, 40, 50]);
const keys = uint8.keys();

keys.next();
keys.next();

console.log(keys.next().value);
// Expected output: 2
Syntaxe Valeur de retour

Un nouvel objet Array Iterator.

Exemples Parcourir un tableau avec for...of
var arr = new Uint8Array([10, 20, 30, 40, 50]);
var eArray = arr.keys();
// prérequis : le navigateur doit supporter les
// boucles for..of et les variables dont la portée
// est définie par let
for (let n of eArray) {
  console.log(n);
}
Une autre méthode d'itération
var arr = new Uint8Array([10, 20, 30, 40, 50]);
var eArr = arr.keys();
console.log(eArr.next().value); // 0
console.log(eArr.next().value); // 1
console.log(eArr.next().value); // 2
console.log(eArr.next().value); // 3
console.log(eArr.next().value); // 4
Spécifications Compatibilité des navigateurs Voir aussi

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