当前位置:网站首页>sessionStorage of BOM series
sessionStorage of BOM series
2022-08-03 13:16:00 【old__L】
目录
1、属性
1.1、length
1.1.1、概述
length 是 sessionStorage 接口的只读属性,返回一个整数,表示存储在 sessionStorage data items in the object(data items)数量.
1.1.2、语法
var aLength = sessionStorage.length;
1.1.3、返回值
一个整数
2、方法
2.1、存储数据
2.1.1、概述
sessionStorage 接口的 setItem() 方法,Accepts a key and value as parameters,will add the key name to the given sessionStorage 对象中,If the key name already exists,则更新其对应的值.
2.1.2、语法
sessionStorage.setItem(keyName, keyValue);
2.1.3、参数
- keyName
一个 DOMString,Indicates the key name to be created or updated.
- keyValue
一个 DOMString,Represents the value corresponding to the key name to be created or updated.
2.1.4、返回值
undefined
2.1.5、异常
in the case of a full storage,调用 setItem() 可能会抛出异常.Developers should always catch setItem() 可能抛出的异常.
2.2、获取数据
2.2.1、概述
getItem() 作为 sessionStorage 接口的方法,accepts a key name(key name)作为参数,and returns the value corresponding to the key name(key’s value).
2.2.2、语法
var aValue = sessionStorage.getItem(keyName);
2.2.3、参数
- keyName
One containing the key name DOMString.
2.2.4、返回值
一个 DOMString,键名对应的值.If the key name does not exist in the store,则返回 null.
2.3、删除数据
2.3.1、概述
sessionStorage 接口的 removeItem() 方法,accepts a key name作为参数,会从给定的 sessionStorage Delete the key name from the object(如果存在). If there is no item matching the given key name,then this method will do nothing.
2.3.2、语法
sessionStorage.removeItem(keyName);
2.3.3、参数
- keyName
一个 DOMString,i.e. the name of the key you want to remove.
2.3.4、返回值
无
2.4、清空数据(所有都清除掉)
2.4.1、概述
clear() 是 sessionStorage 接口的一个方法,Call it to clear all key values in the storage object.
2.4.2、语法
sessionStorage.clear();
2.4.3、参数
无
2.4.4、返回值
无
2.5、键
2.5.1、概述
key() 作为 sessionStorage 接口的方法,接受一个数值 n 作为参数,Returns the stored object No n 个数据项的键名.The order in which keys are stored is defined by the user agent,So try not to rely on this method as much as possible.
2.5.2、语法
var aKeyName = sessionStorage.key(key);
2.5.3、参数
- key
一个整数,Indicates the key name index to get.
2.5.4、返回值
One containing the key name DOMString.
后记
如果你感觉文章不咋地
//(ㄒoㄒ)//,就在评论处留言,作者继续改进;o_O???
如果你觉得该文章有一点点用处,可以给作者点个赞;\\*^o^*//
如果你想要和作者一起进步,可以微信扫描二维码,关注前端老L;~~~///(^v^)\\\~~~
谢谢各位读者们啦(^_^)∠※!!!

边栏推荐
- PyTorch framework to train linear regression model (CPU and GPU environment)
- YOLOv5 training data prompts No labels found, with_suffix is used, WARNING: Ignoring corrupted image and/or label appears during yolov5 training
- An animation optimization of shape tween and optimization of traditional tweening
- Golang channel channel
- Basic principle of the bulk of the animation and shape the An animation tip point
- An introduction to 3D tools
- Sogou news-数据集
- Database basics one (MySQL) [easy to understand]
- Byte's favorite puzzle questions, how many do you know?
- VLAN 实验
猜你喜欢
随机推荐
Five, the function calls
浅谈低代码平台远程组件加载方案
Golang 通道 channel
Oracle is installed (system disk) and transferred from the system disk to the data disk
链游NFT元宇宙游戏系统开发技术方案及源码
Database basics one (MySQL) [easy to understand]
云计算服务主要安全风险及应对措施初探
利用pgsql插件PostGIS 实现地理坐标系数据转换
An动画基础之元件的影片剪辑效果
An动画优化之遮罩层动画
ECCV 2022 | AirDet: 无需微调的小样本目标检测方法
Blog records life
Redis连接池工具类
软件测试自学还是报班好?
[Deep Learning] Overview of Efficient and Lightweight Semantic Segmentation
The Yangtze river commercial Banks to the interview
Redis connection pool tool class
15. PARTITIONS「建议收藏」
Classes and objects (upper)
易观分析:2022年Q2中国网络零售B2C市场交易规模达23444.7亿元









