sessionStorage.removeItem
Removes the key/value pair for the given key from the sessionStorage object
Syntax
sessionStorage.removeItem(key)Parameters
| Parameter | Type | Description |
|---|---|---|
| key | string | The name of the key to remove |
Return Value
undefined
Examples
sessionStorage.removeItem('tempData')
console.log(sessionStorage.getItem('tempData')) // nullfunction clearStep(step: number) {
sessionStorage.removeItem(`step_${step}_data`)
}function cleanupSession() {
const keys = Object.keys(sessionStorage)
keys.filter(k => k.startsWith('temp_')).forEach(k => {
sessionStorage.removeItem(k)
})
}Understanding sessionStorage.removeItem
The sessionStorage.removeItem method in JavaScript removes the key/value pair for the given key from the sessionStorage object. It belongs to the Storage object and is one of the most widely used methods for working with storage values in modern JavaScript and TypeScript applications.
The method signature is sessionStorage.removeItem(key). It accepts 1 parameter: key. When called, it returns undefined. Understanding when and how to use removeItem() helps you write more expressive, readable code.
Common use cases for sessionStorage.removeItem include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like sessionstorage-getitem, sessionstorage-setitem, localstorage-removeitem, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for sessionStorage.removeItem is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
sessionStorage.getItemReturns the value associated with the given key in the sessionStorage, or null if the key does not exist
sessionStorage.setItemAdds a key/value pair to the sessionStorage object for the duration of the page session
localStorage.removeItemRemoves the key/value pair with the given key from the localStorage object
More Storage Methods
Other methods in the Storage object
Related Tools
More Storage Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.