为什么会这样?我需要删除2个键,但只删除1个键
<script>
localStorage.setItem('2', 'lalala')
localStorage.setItem('3', 'lalala')
for (var i = 0 ; i < localStorage.length; i++){
if (localStorage.key(i) > 1)
{
alert (localStorage.key(i)) //show 2 time
localStorage.removeItem(localStorage.key(i)) //remove 1 time (remove 1 key)
}
</script>