★ wanayoo — archive 1999 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/entriesNouvelle recherche | Portail wanayoo

TypedArray.prototype.entries()

2 位贡献者:
我们的志愿者还没有将这篇文章翻译为 中文 (简体) 。加入我们帮助完成翻译!

This is a new technology, part of the ECMAScript 2015 (ES6) standard .
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.

The entries() method returns a new Array Iterator object that contains the key/value pairs for each index in the array.

Syntax

arr.entries()

Examples

Iteration using for...of loop

var arr = new Uint8Array([10, 20, 30, 40, 50]);
var eArray = arr.entries();
// your browser must support for..of loop
// and let-scoped variables in for loops
for (let n of eArray) {
  console.log(n);
}

Alternative iteration

var arr = new Uint8Array([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]

Specifications

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of '%TypedArray%.prototype.entries()' in that specification.
Standard Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 37 (37) Not supported Not supported Not supported
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support Not supported (Yes) 37.0 (37) Not supported Not supported Not supported

See also

文档标签和贡献者

向此页面作出贡献: fscholz, arai
最后编辑者: fscholz,
隐藏侧边栏