Removing a stored item

You can remove a single item from the sessionStorage object. For this, you will need to have the key of the key-value pair you want to remove. This could be anything you no longer need.

Accessing it further in your code will result in null, as shown in the following snippet:

sessionStorage.removeItem('myKey');console.log(sessionStorage.getItem('myKey')); // null

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.