sessionStorage实现数据的增删改查
# sessionStorage实现数据的增删改查 (sessionStorage的方法对比localstorage)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<h3>sessionStorage增删改查</h3>
</head>
<body>
<script>
var key = 'nam';
var value = 'Mike';
var age;
sessionStorage.setItem(key, value);
sessionStorage.age = 18;
console.log(sessionStorage);
sessionStorage.removeItem(key);
sessionStorage.clear();
sessionStorage.setItem('age', 25);
sessionStorage.nam = 'Lucy';
console.log(sessionStorage.getItem('nam'));
console.log(sessionStorage.age);
console.log(sessionStorage.valueOf());
</script>
</body>
</html>