localStorage和sessionStorage的5M存储的单位是什么

发布时间 2023-03-26 23:05:58作者: 樊顺

答案:

web storage 的5M存储的单位是 字符的长度值(或者utf16的编码单元)

注:字符的长度 不等于 字符的个数

localStorage和sessionStorage采用的UTF-16字符编码

'a'.length;
// length: 1

'?'.length;
// length: 2