Obj Storage
# JavaScript Storage Objects
The Web Storage API provides two storage objects, `sessionStorage` and `localStorage`, to add, delete, modify, and query data for web pages.
* `localStorage` is used to store data for the entire website permanently. The stored data has no expiration time until it is manually removed.
* `sessionStorage` is used to temporarily store data for the same window (or tab). The data will be deleted after closing the window or tab.
### Storage Object Properties
| Property | Description |
| --- | --- |
| length | Returns the number of data entries in the storage object. |
### Storage Object Methods
| Method | Description |
| --- | --- |
| key(_n_) | Returns the name of the _n_th key in the storage object. |
| getItem(_keyname_) | Returns the value of the specified key. |
| setItem(_keyname_, _value_) | Adds a key and value. If the corresponding value exists, it updates the value for that key. |
| removeItem(_keyname_) | Removes the key. |
| clear() | Clears all keys in the storage object. |
### Web Storage API
| Property | Description |
| --- | --- |
| [window.localStorage](#) | Stores key/value pairs in the browser. No expiration time. |
| [window.sessionStorage](#) | Stores key/value pairs in the browser. The data will be deleted after closing the window or tab. |
YouTip