Javascript Uint8ClampedArray entries()

Introduction

The Javascript Uint8ClampedArray entries() method returns an iterator object that contains the key/value pairs for each index in the array.

arr.entries()

Iteration using for...of loop

var arr = new Uint8ClampedArray([10, 20, 30, 40, 50]);
var eArray = arr.entries();

for (let n of eArray) {
  console.log(n);//from w  w  w.ja  va2 s. co m
}

Alternative iteration

var arr = new Uint8ClampedArray([10, 20, 30, 40, 50]);
var eArr = arr.entries();
console.log(eArr.next().value); // [0, 10]
console.log(eArr.next().value); // [1, 20]
console.log(eArr.next().value); // [2, 30]
console.log(eArr.next().value); // [3, 40]
console.log(eArr.next().value); // [4, 50]



PreviousNext

Related