这篇翻译不完整。请帮忙从英语翻译这篇文章。
概要
Uint32Array
表示一个32位的无符号的整数数组,以字节的形式。 如果需要以字节的形式操作,使用{jsxref("DataView")}}代替。 内容初始化为0。 一旦创建,你可以用对象的方法引用数组里的元素,或者使用标准的数组index语法(即,使用中括号)。
语法
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 theUint32Array
Fixed at construction time and thus read only. -
Uint32Array.prototype.byteLength
只读 -
Returns the length (in bytes) of the
Uint32Array
from the start of itsArrayBuffer
. Fixed at construction time and thus read only. -
Uint32Array.prototype.byteOffset
只读 -
Returns the offset (in bytes) of the
Uint32Array
from the start of itsArrayBuffer
. 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 6 (ECMA-262) TypedArray constructors |
Release Candidate | 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 |