Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added undefined example

  • Loading branch information...
commit 0e4ac1aadb986a11923059bc7c57259e28613777 1 parent c035178
@hunterloftis authored
Showing with 26 additions and 2 deletions.
  1. +15 −2 README.md
  2. +11 −0 examples/undefined.js
View
17 README.md
@@ -50,8 +50,21 @@ hydrated.hello(); // Hunter says hello!
### Undefined
-`JSON.stringify()` loses properties that are `undefined`.
-Cryo takes a verbatim snapshot of all your properties, including those that are `undefined`.
+Cryo takes a verbatim snapshot of all your properties, including those that are `undefined` - which JSON ignores.
+
+```js
+var Cryo = require('../lib/cryo');
+
+var obj = {
+ defaultValue: undefined
+};
+
+var withJSON = JSON.parse(JSON.stringify(obj));
+console.log(withJSON.hasOwnProperty('defaultValue')); // false
+
+var withCryo = Cryo.parse(Cryo.stringify(obj));
+console.log(withCryo.hasOwnProperty('defaultValue')); // true
+```
### Date
View
11 examples/undefined.js
@@ -0,0 +1,11 @@
+var Cryo = require('../lib/cryo');
+
+var obj = {
+ defaultValue: undefined
+};
+
+var withJSON = JSON.parse(JSON.stringify(obj));
+console.log(withJSON.hasOwnProperty('defaultValue')); // false
+
+var withCryo = Cryo.parse(Cryo.stringify(obj));
+console.log(withCryo.hasOwnProperty('defaultValue')); // true
Please sign in to comment.
Something went wrong with that request. Please try again.