--- title: Storage.removeItem() slug: Web/API/Storage/removeItem translation_of: Web/API/Storage/removeItem ---
{{APIRef("Web Storage API")}}
O método removeItem()
da interface {{domxref("Storage")}}, quando passado um nome de chave, irá remover essa chave do armazenamento.
storage.removeItem(keyName);
Nenhum valor de retorno.
A função a seguir cria três itens de dados no armazenamento local, em seguida, remove o item "image".
function populateStorage() { localStorage.setItem('bgcolor', 'red'); localStorage.setItem('font', 'Helvetica'); localStorage.setItem('image', 'myCat.png'); localStorage.removeItem('image'); }
Nota: Para ver o uso em um exemplo prático veja nosso Web Storage Demo.
Especificação | Status | Comentários |
---|---|---|
{{SpecName('Web Storage', '#dom-storage-removeitem', 'removeItem()')}} | {{Spec2('Web Storage')}} |
{{ CompatibilityTable() }}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
localStorage | 4 | 3.5 | 8 | 10.50 | 4 |
sessionStorage | 5 | 2 | 8 | 10.50 | 4 |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | 2.1 | {{ CompatUnknown }} | 8 | 11 | iOS 3.2 |
All browsers have varying capacity levels for both localStorage and sessionStorage. Here is a detailed rundown of all the storage capacities for various browsers.
Note: since iOS 5.1, Safari Mobile stores localStorage data in the cache folder, which is subject to occasional clean up, at the behest of the OS, typically if space is short.