Skip to content

Commit a8d5286

Browse files
Connormihaljharb
authored andcommitted
[Robustness] stringify: avoid relying on a global undefined (#427)
1 parent 04eac8d commit a8d5286

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
@@ -111,7 +111,7 @@ var stringify = function stringify(
111111

112112
for (var j = 0; j < objKeys.length; ++j) {
113113
var key = objKeys[j];
114-
var value = typeof key === 'object' && key.value !== undefined ? key.value : obj[key];
114+
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
115115

116116
if (skipNulls && obj[key] === null) {
117117
continue;
@@ -160,7 +160,7 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
160160
return defaults;
161161
}
162162

163-
if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
163+
if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
164164
throw new TypeError('Encoder has to be a function.');
165165
}
166166

0 commit comments

Comments
 (0)