2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-09-29 23:03:28 +02:00
|
|
|
title: Store.setIfUnset()
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-09-29 23:03:28 +02:00
|
|
|
The `Store.set()` method stores the value of `value` in the store under key
|
|
|
|
`key`, but only if that key does not already hold a value.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
|
|
|
```js
|
|
|
|
Store store.set(mixed key, mixed value)
|
|
|
|
```
|
|
|
|
|
2024-09-28 13:13:48 +02:00
|
|
|
:::tipThis method is chainable as it returns the `Store` object:::
|
2022-09-29 23:03:28 +02:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
```js
|
2022-09-29 23:03:28 +02:00
|
|
|
const store = new Store()
|
|
|
|
store.set('example', 'Hi there')
|
|
|
|
store.setIfUnset('example', 'Hi again') // This has no effect
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
|
|
|
|