Skip to content

Commit 4e312c4

Browse files
Connormihaljharb
authored andcommitted
[Robustness] stringify: avoid relying on a global undefined (#427)
1 parent 57918da commit 4e312c4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/stringify.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ var stringify = function stringify(
119119

120120
for (var j = 0; j < objKeys.length; ++j) {
121121
var key = objKeys[j];
122-
var value = typeof key === 'object' && key.value !== undefined ? key.value : obj[key];
122+
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
123123

124124
if (skipNulls && value === null) {
125125
continue;
@@ -154,7 +154,7 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
154154
return defaults;
155155
}
156156

157-
if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
157+
if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
158158
throw new TypeError('Encoder has to be a function.');
159159
}
160160

0 commit comments

Comments
 (0)