• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • Uint32Array

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

    语法

    new Uint32Array(); // new in ES2017
    new Uint32Array(length);
    new Uint32Array(typedArray);
    new Uint32Array(object);
    new Uint32Array(buffer [, byteOffset [, length]]);
    

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

    属性

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

    方法

    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);
    

    上篇:Int32Array

    下篇:Float32Array