Safely set a local storage key to a specific value
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string
|
localStorage key to set |
value |
string
|
new localStorage value |
Returns:
- Type:
-
Boolean
- returns true/false if operation succeeded without error.
Example
setLocalStorage('foo', 'bar'); // sets localStorage key `foo` to 'bar'