Browse Source

update null examples

master
AJ ONeal 6 years ago
parent
commit
2e4745b189
  1. 17
      README.md

17
README.md

@ -97,6 +97,23 @@ null === store.get('non-existant-key');
The special case of `null` as `"null"`, aka `"\"null\""`:
```
typeof null // object
typeof "null" // string
typeof "\"null\"" // string
```
`null`, and `"null"` both parse as `null` the "object", instead of one being the string (which would be `"\"null\""`).
```
JSON.parse(null) // null (object)
JSON.parse("null") // null (object)
JSON.parse("\"null\"") // 'null' (string)
```
Objects containing `null`, however, parse as expected `{ "foo": null, "bar": "null" }` will parse as `foo` being `null` but `bar` being `"null"`, much unlike the value `"null"` being parsed on its own.
```
JSON.parse('{ "foo": null }') // { foo: null }
JSON.parse('{ "foo": "null" }') // { foo: 'null' }
```
Loading…
Cancel
Save