diff --git a/src/objects.js b/src/objects.js index 9047194..be0d70e 100644 --- a/src/objects.js +++ b/src/objects.js @@ -234,7 +234,7 @@ export function stringify (obj, options = {}) { switch (obj) { case undefined: case null: - return obj; + return obj + ""; } switch (typeof obj) { diff --git a/tests/stringify.js b/tests/stringify.js index 8c5e682..36be78e 100644 --- a/tests/stringify.js +++ b/tests/stringify.js @@ -3,6 +3,8 @@ import { stringify } from "../src/util.js"; export default { run: stringify, tests: [ + { arg: undefined, expect: "undefined" }, + { arg: null, expect: "null" }, { arg: 1, expect: "1" }, { arg: NaN, expect: "NaN" }, { arg: "foo", expect: '"foo"' },