TypedArray & ArrayBuffer
TypedArray & ArrayBuffer
| Type | Each element size in bytes |
|---|---|
| Int8Array | 1 |
| Uint8Array | 1 |
| Uint8ClampedArray | 1 |
| Int16Array | 2 |
| Uint16Array | 2 |
| Int32Array | 4 |
| Uint32Array | 4 |
| Float32Array | 4 |
| Float64Array | 8 |

1 字节(1 bytes) === 8位
8位 占用 1 字节(1 bytes)
16位 占用 2 字节(2 bytes)
32位 占用 4 字节(4 bytes)
64位 占用 8 字节(8 bytes)
TypedArray
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
/*
Type Each element size in bytes
Int8Array 1
Uint8Array 1
Uint8ClampedArray 1
Int16Array 2
Uint16Array 2
Int32Array 4
Uint32Array 4
Float32Array 4
Float64Array 8
*/
// 1 字节(1 bytes) === 8位
// 8位 占用 1 字节(1 bytes)
// 16位 占用 2 字节(2 bytes)
// 32位 占用 4 字节(4 bytes)
// 64位 占用 8 字节(8 bytes)
// create a TypedArray with a size in bytes
const typedArray1 = new Int8Array(8);
typedArray1[0] = 32;
const typedArray2 = new Int8Array(typedArray1);
typedArray2[1] = 42;
console.log(typedArray1);
// [32, 0, 0, 0, 0, 0, 0, 0]
console.log(typedArray2);
// [32, 42, 0, 0, 0, 0, 0, 0]
ArrayBuffer
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
const buffer = new ArrayBuffer(8);
// ️ buffer 不可以直接读取, 必须创建对应的 view
const view = new Int32Array(buffer);
demo
https://www.freecodecamp.org/learn/coding-interview-prep/data-structures/typed-arrays
refs
MarkDown Table
| Type | Each element size in bytes |
|---|---|
| Int8Array | 1 |
| Uint8Array | 1 |
| Uint8ClampedArray | 1 |
| | |
| Int16Array | 2 |
| Uint16Array | 2 |
| | |
| Int32Array | 4 |
| Uint32Array | 4 |
| | |
| Float32Array | 4 |
| Float64Array | 8 |
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#tables
https://www.tablesgenerator.com/markdown_tables
xgqfrms 2012-2020
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
TypedArray & ArrayBuffer的更多相关文章
- Chakra调试笔记 TypedArray
一.TypedArray类型 TypedArray是漏洞中常见到的结构,手册用法有四 1.new TypedArray(length); //byteLength=length * sizeof(Ty ...
- HTML5 类型数组TypeArray(一)
1.起源 TypedArray是一种通用的固定长度缓冲区类型,允许读取缓冲区中的二进制数据. 其在WEBGL规范中被引入用于解决Javascript处理二进制数据的问题. TypedArray已经被大 ...
- ES6学习一 JS语言增强篇
一 背景 JavaScript经过二十来年年的发展,由最初简单的交互脚本语言,发展到今天的富客户端交互,后端服务器处理,跨平台(Native),以及小程序等等的应用.JS的角色越来越重要,处理场景越来 ...
- node Buffer.byteLength()
Buffer.byteLength(string[, encoding]) string {String} | {Buffer} | {TypedArray} | {DataView} | {Arra ...
- node.js传参给PHP失败,headers加上'Content-Length': Buffer.byteLength(content)
node.js需要传参给PHP,执行计划任务 var events = require('events'); start_cron(,,{"auth":"7wElqW6v ...
- js data type checker
js data type checker js 数据类型检测 "use strict"; /** * * @author xgqfrms * @license MIT * @cop ...
- ArrayBuffer和TypedArray,以及Blob的使用
前端使用TypedArray编辑二进制 ES6提供了, ArrayBuffer和TypedArray, 让前端也可以直接操作编辑二进制数据, 网页中的类型为file的input标签, 也可以通过Fil ...
- ArrayBuffer对象、TypedArray视图和DataView视图
转:http://es6.ruanyifeng.com/#docs/arraybuffer ArrayBuffer ArrayBuffer 对象 TypedArray 视图 复合视图 DataView ...
- ArrayBuffer、TypedArray、DataView二进制数组
三个是处理二进制数据的接口.都是类数组. 1.ArrayBuffer是什么? ArrayBuffer是一个二进制对象(文件,图片等).它指向固定长度的,连续的内存区域. const buffer = ...
随机推荐
- 一种优化递归算法的方法(javascript)
看书的时候看到了这个比较酷的方法,分享一下. 一.问题描述:代码如下,我们以计算阶乘(factorial)为例,当重复调用factorial(9),factorial(8),factorial(7)的 ...
- 为什么MySQL索引使用B+树
为什么MySQL索引使用B+树 聚簇索引与非聚簇索引 不同的存储引擎,数据文件和索引文件位置是不同的,但是都是在磁盘上而不是内存上,根据索引文件.数据文件是否放在一起而有了分类: 聚簇索引:数据文件和 ...
- 页面切换提速30%!京东商城APP首屏耗时监控及优化实践
https://mp.weixin.qq.com/s/vIG_x1MWC33HKV1GxalVHg 原创 平台研发朱跃棕等 京东零售技术 2020-12-09 网络接口请求可以从接口结构合理性及多接口 ...
- 函数式编程 偏函数 生成器 yield
高阶函数 # 高阶函数def f(x): return x * x# map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次作用到序列的每个元素,并把结果作为新的Ite ...
- 「笔记」AC 自动机
目录 写在前面 定义 引入 构造 暴力 字典图优化 匹配 在线 离线 复杂度 完整代码 例题 P3796 [模板]AC 自动机(加强版) P3808 [模板]AC 自动机(简单版) 「JSOI2007 ...
- debian 屌丝日记
好几年前,刚开始学习linux时,写的笔记,现在看来还挺有意思的,发出来 纪念下 1.安装debian系统,只安装最基本系统 不要桌面,不要print server,具体不会看网上图文并茂的 1) ...
- mysql int类型 int(11) 和int(2)区别
CREATE TABLE `learn` ( `id` int(11) unsigned NOT NULL, `exp` int(2) DEFAULT 0, PRIMARY KEY (`id`)) E ...
- 常用的正则表达式@java后台
package Regex; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @作者 Goofy * @邮件 ...
- 换一种视角看DNS(采坑篇)
换一种视角看DNS 我们尽量用精炼的语言,尽可能的规划DNS的全貌(当然笔者水平有限,如有错误请不吝赐教). 通常啊我们在个人PC中能看到DNS的配置身影就是在上网的时候,通常如果你不配置DNS可能找 ...
- Pytest(8)parametrize参数化
前言 当某个接口中的一个字段,里面规定的范围为1-5,你5个数字都要单独写一条测试用例,就太麻烦了,这个时候可以使用pytest.mark.parametrize装饰器可以实现测试用例参数化. 官方示 ...