x
 
<!DOCTYPE html>
<html>
<body>
<h1>Storage length 属性</h1>
<p>本例演示如何使用 length 属性获取存储在本地存储对象中的项目数。</p>
<button onclick="myFunction()">获取存储项目的数量</button>
<p id="demo"></p>
<script>
function myFunction() {
  var x = localStorage.length;
  document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>