diff --git a/README.md b/README.md index 8d6f2af..bb9be90 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ API **NOTE**: You cannot omit optional parameters. Use `null` if you want accepts the defaults for some things and provide a values for others. For example: `JsonStorage.create(null, null, { stringify: false })` -null vs undefined in JSON +JSON / DOMStorage Conversion Gotchas === These notes do not reflect a bugs or defects in this library, @@ -71,6 +71,8 @@ they're simply to inform you of a few 'gotchas' inherent in JSON / DOMStorage co If they do, you're probably doing something wrong in the first place. +### `undefined` vs `null` + It is not valid to set `undefined` in JSON. So setting a key to `undefined` will remove it from the store. This means that `store.set('x')` is the same as `store.remove('x')`. @@ -85,6 +87,8 @@ Note that both values that exist as `null` and values that don't exist at all wi null === store.get('non-existant-key'); +### `null` vs `"null"` + The special case of `null` as `"null"`, aka `"\"null\""`: `null`, and `"null"` both parse as `null` the "object", instead of one being the string (which would be `"\"null\""`).