update null examples

This commit is contained in:
AJ ONeal 2018-07-31 16:58:36 +00:00
parent 21098984f1
commit 2e4745b189
1 changed files with 17 additions and 0 deletions

View File

@ -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' }
```