Can't remove LocalStorage Item with .removeItem

Viewed 16124

I'm trying to remove a localStorage with .removeItem(keys) but it's said the localStorage keys is not defined. I'm trying to make a simple localStorage again like below, and then trying to removeItem again, still the same problem. What's wrong?

<html>
<head>
    <script>
        localStorage.test = "good";
        console.log(localStorage.test);
        localStorage.removeItem(test);
    </script>
</head>

The browser said, "Uncaught ReferenceError: test is not defined". I'm trying using window.localStorage.clear(), it's work, but I want to specify which localStorage I want to delete.

1 Answers
Related