Skip to content

javascript中将uint8array二进制数组转为普通的js数组 #6

@codeceo-net

Description

@codeceo-net

ECMAScript 在6版本中引入了直接操作内存的二进制数组数据,这样避免数据转换带来的性能影响。

下面举例将 uint8array() 数组转为 普通的数组

构造
uint8Array = new Uint8Array( length );或
uint8Array = new Uint8Array( buffer数组 );
转换的2种方法:
(1) var array = Array.from(uint8Array)
(2)var array = [].slice.call(uint8Array)
还有更多的typearray 使用方法了解,连接:http://javascript.ruanyifeng.com/stdlib/arraybuffer.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions