MDN wants to talk to developers like you: https://qsurvey.mozilla.com/s3/8d22564490d8

Uint32Array

这篇翻译不完整。请帮忙从英语翻译这篇文章

概要

Uint32Array表示一个由基于平台字节序的32位无符号字节组成的数组.如果需要对字节顺序进行控制(译者注:即 littleEndian 或 bigEndian),请使用DataView代替.数组中每个元素的初始值都是0.一旦创建,你可以用对象的方法引用数组里的元素,或者使用标准的数组索引语法(即,使用中括号)。

语法

Uint32Array(length);
Uint32Array(typedArray);
Uint32Array(object);
Uint32Array(buffer [, byteOffset [, length]]);

更多的构造器语法和属性请参照 TypedArray

属性

Uint32Array.BYTES_PER_ELEMENT
返回一个number类型的值,表示元素的size。 Uint32Array 返回4。
Uint32Array.length
长度属性,它的值是3。
Uint32Array.name
返回字符串类型的值,表示构造器的名字。Uint32Array 的返回值是: "Uint32Array"。
Uint32Array.prototype
返回 TypedArray 对象的原型链。

Methods

Uint32Array.from()
参考Array.from()。 未完成,请参考bug 896608
Uint32Array.of()
参考Array.of()。未完成,请参考 bug 896608.

Uint32Array prototype

所有Uint32Array 对象继承自 %TypedArray%.prototype.

Properties

Uint32Array.prototype.constructor
返回创建实例原型的函数。 默认返回 Uint32Array 的构造器。
Uint32Array.prototype.buffer 只读
Returns the ArrayBuffer referenced by the Uint32Array Fixed at construction time and thus read only.
Uint32Array.prototype.byteLength 只读
Returns the length (in bytes) of the Uint32Array from the start of its ArrayBuffer. Fixed at construction time and thus read only.
Uint32Array.prototype.byteOffset 只读
Returns the offset (in bytes) of the Uint32Array from the start of its ArrayBuffer. Fixed at construction time and thus read only.
Uint32Array.prototype.length 只读
Returns the number of elements hold in the Uint32Array. Fixed at construction time and thus read only.

Methods

Uint32Array.prototype.copyWithin()
See Array.prototype.copyWithin().
Uint32Array.prototype.move() 未实现
Former non-standard version of Uint32Array.prototype.copyWithin().
Uint32Array.prototype.set()
Stores multiple values in the Uint32Array, reading input values from a specified array.
Uint32Array.prototype.subarray()
Returns a new Uint32Array from the given start and end element index.

Examples

// From a length
var uint32 = new Uint32Array(2);
uint32[0] = 42;
console.log(uint32[0]); // 42
console.log(uint32.length); // 2
console.log(uint32.BYTES_PER_ELEMENT); // 4

// From an array
var arr = new Uint32Array([21,31]);
console.log(arr[1]); // 31

// From another TypedArray
var x = new Uint32Array([21, 31]);
var y = new Uint32Array(x);
console.log(y[0]); // 21

// From an ArrayBuffer
var buffer = new ArrayBuffer(16);
var z = Uint32Array(buffer, 0, 4);

Specifications

Specification Status Comment
Typed Array Specification Obsolete Superseded by ECMAScript 6.
ECMAScript 2015 (6th Edition, ECMA-262)
TypedArray constructors
Standard Initial definition in an ECMA standard.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 7.0 4.0 (2) 10 11.6 5.1
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 4.0 (Yes) 4.0 (2) 10 11.6 4.2

See also

文档标签和贡献者

 此页面的贡献者: liyongleihf2006, chyee
 最后编辑者: liyongleihf2006,