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

答案:

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

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

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

'a'.length;
// length: 1

'𠮷'.length;
// length: 2

 

posted @ 2023-03-26 22:59  樊顺  阅读(28)  评论(0编辑  收藏  举报