这个 达雷。缓冲区() 是JavaScript中的一个属性,表示typedArray引用的ArrayBuffer和 达雷。byteLength() 表示类型Darray的长度(字节)。 语法:
null
typedArray.buffer typedarray.byteLength
参数: 它不接受任何参数,因为它是属性而不是函数。 返回值: 它不返回任何值。
<script> // creating some ArrayBuffers with a size in bytes const buffer1 = new ArrayBuffer(8); const buffer2 = new ArrayBuffer(12); const buffer3 = new ArrayBuffer(20); const buffer4 = new ArrayBuffer(22); const buffer5 = new ArrayBuffer(4); // Creating typedArray object for above buffers const A = new Uint16Array(buffer1); const B = new Uint16Array(buffer2); const C = new Uint16Array(buffer3); const D = new Uint16Array(buffer4); const E = new Uint16Array(buffer5); // Getting the length of the arrayBuffer document.write(A.byteLength + "<br>" ); document.write(B.byteLength + "<br>" ); document.write(C.byteLength + "<br>" ); document.write(D.byteLength + "<br>" ); document.write(E.byteLength); </script> |
输出:
8 12 20 22 4
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END