diff --git a/README.md b/README.md index a8720f7..0183b81 100644 --- a/README.md +++ b/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' } +``` \ No newline at end of file