[英]A vanilla Array of Floats from an ArrayBuffer
There are a number of questions and resources about getting Typed arrays from an ArrayBuffer
.有许多关于从
ArrayBuffer
获取类型化数组的问题和资源。 An example: How to get an array from ArrayBuffer?一个例子: 如何从 ArrayBuffer 获取一个数组? .
. I need an actual array
我需要一个实际的数组
I tried Array.from(myArrayBuffer)
and get this:我试过
Array.from(myArrayBuffer)
并得到这个:
// buf is an ArrayBuffer(878468)
Array.from(buf) // Array(0) length: 0
It seems there were no direct conversion from ArrayBuffer
to a vanilla array.似乎没有从
ArrayBuffer
直接转换为 vanilla 数组。 Two steps are needed需要两步
So:所以:
let ab = new ArrayBuffer(1000)
let arr = Array.from(new Float32Array(ab))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.