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

TypedArray.prototype.values() - JavaScript | MDN

TypedArray.prototype.values()

Baseline Widely available

La méthode values() renvoie un nouvel objet Array Iterator qui contient les valeurs pour chaque indice du tableau.

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

array1.next();
array1.next();

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

Un nouvel objet Array Iterator.

Exemples Parcourir le tableau typé avec for...of
var arr = new Uint8Array([10, 20, 30, 40, 50]);
var eArray = arr.values();
// 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.values();
console.log(eArr.next().value); // 10
console.log(eArr.next().value); // 20
console.log(eArr.next().value); // 30
console.log(eArr.next().value); // 40
console.log(eArr.next().value); // 50
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